0
\$\begingroup\$

I have a particular GameObject with Rigidbody which I'm trying to move over time. If I move the object using its transform.position, it works fine. However, if I move the object using rigidbody.position or rigidbody.MovePosition(), it does not move as expected. It should be moving up and forward (+Y and +Z). Instead, it oscillates up and down but does not move on the X or Z axis.

I do not have any constraints enabled on the Rigidbody, and I can't find anywhere in my code that would freeze or alter its position, besides the line of code that's supposed to move it, and its behavior is the same whether or not gravity or colliders are enabled.

Is there some way to view a list of inputs that are affecting the position and movement of a particular Rigidbody each frame?

\$\endgroup\$
2
  • \$\begingroup\$ Paste the code you have written. \$\endgroup\$ Jan 10, 2020 at 5:27
  • \$\begingroup\$ I don't know of a general debugging view like you describe, but if you walk us through the steps to build a Minimal, Complete, Verifiable Example scene that reproduces the problem you're observing, we can try to help you debug this specific case. \$\endgroup\$
    – DMGregory
    Jan 10, 2020 at 13:07

1 Answer 1

0
\$\begingroup\$

It turned out that the GameObject was a child of another GameObject. The parent was rocking back and forth slightly, which created the oscillating movement and apparently overrode and nullified attempts to move the GameObject through rigidbody.position or rigidbody.MovePosition(). I solved the issue by removing the GameObject from its parent and making it a root object of the scene.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .