- Home /
How do I cause the collision of one object affect the movement of another object?
I have 3 objects:
1) A sphere that the player will control
2) A cube that the player will pick up
3) Another sphere that will automatically roll to a new position when the cube is picked up
I have added the code for picking up the pick-up object:
void OnTriggerEnter (Collider other)
{
if(other.gameObject.CompareTag ("PickUp"))
{
other.gameObject.SetActive(false);
}
}
Now what can I add to this code if I want the second sphere to roll to a new position once the cube is picked up?
Sorry, this question is much too generic. It's about Unity and program$$anonymous$$g basics like moving objects and managing references, which can easily be learned elsewhere. We do not address such questions at UA. Refer to the on-site lessons and any other learning materials you can find.
Your script needs a reference to the object you wish to act upon. That object must be told to move over time in whatever way you see fit.
Since someone else passed this through moderation, I guess I won't remove it.
Your answer
Follow this Question
Related Questions
pop up between 2 colliders: bug or not? 1 Answer
sphere gets into cube 1 Answer
specifying collider OnTriggerEnter 1 Answer
Sphere clipping in cube 1 Answer
Colliders that do not collide... 1 Answer