- Home /
on mouse click get other object to move away
Hi I'm working in C# and im looking for any code suggestions that would allow me on clicking an object for it to change state and case other ovjects to move away from it for a certain distance and then stop moving.
Also on pressing a key to get the opposite to happen.
Ive looked on the unity website and i'm not sure what transform funtion to use any thoughts?
cheers
Answer by Catlard · May 04, 2012 at 12:35 PM
You probably want to have each of the objects moving towards the one object have a script on it. When you want to change the objects' directions, have a script find all the objects that are moving towards the one object, and change some variable so that they're moving in the opposite direction. Probably just have to multiply the speed by -1.
Your answer
Follow this Question
Related Questions
save and move to mouse click positions 1 Answer
How to move object to the position of another object while clicked on it? 1 Answer
Trying to move a instantiate gameobject with mousedown 1 Answer
Transform.position problem Please help? 1 Answer
How can I move an object to a clicked objects (center of X,Z) coordinates (board game)? 0 Answers