Rigid Body Position differs from object transform

I see a couple of other people have had this issue and after spending an hour in unity docs I think it might be worth calling this out in the video. What happened to me is that when the ball is locked to the paddle the transform of the ball shows it in the right place but transform of the rigid body (you can see it in the info box) drops like a rock, triggering the lose collider. Couple of questions from me, is rigid body supposed to wander off from it’s object like that? If so how is that normally handled and, based on the unity docs, should we be using transform on a dynamic object at all? This feels like a future debugging nightmare as it only happens on one of my computers and not the other :slight_smile:

Hi Des,

It is. Unity is highly optimised and does not compare the position of the transform with the position of the collider each frame. At least, that’s what I suspect. Most of Unity is not open-source.

We move the game object by manipulating transform.position directly but the physics simulation does its own calculations, which causes a conflict. If it doesn’t cause a conflict, you are lucky. Rick is lucky.

What you could do to fix the issue is to set the simulated variable of the Rigidbody2D to false in Start. When the ball gets launched, set it to true.

That was what I’d eventually gone with from the unity docs, nice to know I’m not completely crazy. Thanks for the reply!

You’re welcome. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms