Hi all,
I m developing “I got it” game, its a real life carnival game. I have setup game world and create box crate. Now i having difficulties in:
How can i know if ball is inside a cube ? i have added rigid body to a ball and set up mesh collider on a 3d cude model, so that ball can go inside cude and stay there just like real life game, but how can i find this condition and check mark that ball ‘X’ is now staying inside Cube X and its velocity is now zero (sometimes it keeps rotating slowly here and there in the box not resting completely).
Secondly i dont want that if a ball is already inside ‘X’ Cube, than other ball should not stop over it, it should pass that cube and drop inside some other Cube.
Looking forward for a positive reply.
Thanks.
@faisal007, I hope I have understood your requirements correct.
How can i know if ball is inside a cube ? i have added rigid body to a ball and set up mesh collider on a 3d cude model, so that ball can go inside cude and stay there just like real life game, but how can i find this condition and check mark that ball ‘X’ is now staying inside Cube X and its velocity is now zero (sometimes it keeps rotating slowly here and there in the box not resting completely).
- Add another cube inside your crate.
- Change it’s BoxCollider to trigger
mode.
- Add a custom script to the
cube with an OnTriggerEnter
method. This method will be called
when ever a ball enters the cube.
Here you can mark the ball as being
inside the crate.
- Remove or disable
the renderer of the cube.
Secondly i dont want that if a ball is already inside ‘X’ Cube, than other ball should not stop over it, it should pass that cube and drop inside some other Cube.
When the ball touches the bottom of the inside of the crate you can change it’s Rigidbody to be kinematic so it won’t be affected by physics and disable the ball’s collider so other balls can pass.
Looking forward for a positive reply.
Cheers mate,
Robin
Hello,
Thanks for the reply, i will test it out and post back here.
Thanks.