hi friends
i am new in unity
i want to do the following task
i have two object,
when i move one object near to other the second object move back
please please help me for this task
![]()
hi friends
i am new in unity
i want to do the following task
i have two object,
when i move one object near to other the second object move back
please please help me for this task
![]()
I’m not sure exactly what you mean here. Do you want the two objects to stay the same distance apart or do you want one to push the other away when it gets close (like a spring)?
I want to do the two objects to stay the same distance apart
The easiest way is to set one object to be the parent of the other. You can do this in the Hierarchy panel by dragging one object onto the other. If you need to do it from a script, set one object’s transform.parent property to the other object’s transform.