I am making this ball and platform game and I have added some moving platforms that move vertically (up and down) but when the platform goes down, the ball stays in the air and starts to fall down to the platform. How can I fix this?
1 Answer
1I believe this is similar to the problem I was facing a while ago. What I did: create an empty game object and make it a child of your platform. Add a box collider to the empty game object and set it as trigger. Make sure the trigger is a bit bigger than the collider on your platform.
Add a script to your ball with the following code:
void OnTriggerEnter(Collider col)
{
gameObject.transform.parent = col.transform.root;
}
void OnTriggerExit(Collider col)
{
gameObject.transform.parent = null;
}
says error :( the script doesnt work
– MTDues