how can i move my gameobject on mouse click by script??
sorry about my english but i need help please
i want to know unity's c# script use for the game that i planinig
but i could not use any location learning c# for my level (=low, very low level)
so i first want to move gameobject on mouse click
like starcraft unit or legueoflegend champion move liike
for this move what script need?
i'm sorry again my english but help need so much
Answer by jaesumg · Feb 03, 2017 at 07:00 AM
dear makri907 Transform player; void Start(){ player = gameObject.Getcomponent(); } void Update(){ if(input.GetMouseButtonDown(0)){ //Manipulate the player transform here... } } So Thank you about your answer, I now study in academy but I still not well cording I was busy so I couldn't check your answer I'm so sorry
Answer by kartikips · Feb 03, 2017 at 07:26 AM
First of all read some unity documentation and GetMouseButtonDown() is used to move object on click of mouse button. and in unity input manager handles all the input related events so here is the link of Input but GetMouseButtonDown() solves your problem.
He asked to move an object when the mouse button is clicked. Get$$anonymous$$ouseButtonDown is correct in this instance.
Thank you $$anonymous$$akri907 I find unity script API Get$$anonymous$$ouseButtonDown(0), now i trying to Ray ray
Your answer
Follow this Question
Related Questions
Move only if mouse click the Terrain 0 Answers
How to move a game object to a position after selecting it 0 Answers
Movement input problem? 1 Answer
2D Object following the cursor without glitchyness at the center 0 Answers
Game Object jumps to z-axis 0 Answers