- Home /
Why are these object passing through each other?
Okay, so as can be seen in the Gif below I have a scene in which I am trying to recreate a game like the "Tipping Point" game-show. The scene is made up of:
_
One box object with a collider to make up the backboard
A number of cylinder object each with a collider to make the pegs
One box object with collider and transparent material to make up front screen.
A number of box objects with colliders to create the board and zone edges
A box object with a collider and a script containing a mathf.pingpong function to make up the moving top shelf
A box object with a collider to make up the static bottom shelf
The Tokens, which are made with a pro-builder cylinder and collider and have a script which uses the addtorque and the addforce functions
The problem is, as shown in the gif below, as when the token drops and hits the lower shelf it simply phases through the shelf, along with the rear-most one which begin on the top shelf. I don't understand why the physics of this is having a problem. When I turn off the script which moves the top shelf the token falls and rests on the shelf with no phasing problem, so I can be sure that it has something to do with the moving platform. is there a better way to achieve the movement of the shelf which allows for better physics calculations?
Unity Object "Phasing" Glitch Gif - link:https://imgur.com/a/nhSqqvC
Thank you all in advance, I look forward to any help at all.
Kind Regards,
Cheyne
Answer by Edy · Aug 13, 2021 at 10:20 AM
A box object with a collider and a script containing a mathf.pingpong function to make up the moving top shelf
Most likely the problem is here. Simply using a boxcollider and moving it's transform won't produce the expected physics effects in other rigidbodies.
In order for that setup to work the moving shelf must be a kinematic Rigidbody moved by calling Rigidbody.MovePosition() from FixedUpdate(). You can easily adapt your Mathf.PingPong-based code for that.
Your answer
Follow this Question
Related Questions
Slope limiting with Rigidbody 0 Answers
Coroutine fires once after destroying gameobjects in a scene and recreating new objects 0 Answers
Car Movment Script not fully working!!!!!!! 1 Answer
My gameobject only moves to the right once and then stops, why? 3 Answers
My player's movement is slippery 1 Answer