- Home /
Collider lets object through
I have a "platform" (rectangle) and a square, and I want for the platform to be moving up and down and push the square up and down. However, during runtime, when I move the platform in the editor to push the square, it either has a very jittery motion, or the collider just lets the object go through it. WHy can't I just get the platform to smoothly push the box up and down?
Note: Yes, I made sure they both had rigidbodies, and their colliders are not triggers. I do, however, have a script on the square, which constantly lerps the square toward it's own position (I have my own reason for that) I don't think that is causing the problem, but it might be.
$$anonymous$$oving objects from the editor like that won't produce physically accurate collisions, your rectangle is not physically moving into the square, its being teleported into it. It would be better to test this by creating a script to physically move the rectangle up and down, and test it in play mode.
have a script on the square, which constantly lerps the square toward it's own position
Could you elaborate? Lerping something towards itself would just return the same value, and should do nothing as far as I know.
Thank you! I am a noob with unity, so I wasn't completely aware of how the editor worked. I wrote a quick script to translate the platform up, and sure enough, it had smooth movement. Thank you! @bobisgod234
these kind of problems are always tricky, but keep in $$anonymous$$d that the physics system can be overridden by other forms of motion. so dragging on the handles in the editor will always override physics if you push hard enough. if you're using transform.Translate, or setting transform.position this can also 'push too hard' so to speak. The jittering is cause by the transform set moving the object forward and the physics set moving it back over and over again.
The accuracy of physics calculations can be increased by changing the fixed timestep (Edit - Project Settings - Time - Fixed Timestep) but this costs performance.