Hello,
I have a problem where I would like my game object’s transform to update every time physics is active on the game object. When I use the 2 lines,
to attempt to make my game object’s transform update according to what is happening when I apply a force to it, it sort of works but my game object is rather jumpy. It jumps from one rigidbody position to another every time physics updates, and so the game object doesn’t move along the game smoothly like I want it to which makes me wonder if physics is on a separate thread that is separate from a transform. How can I fix this problem where the object’s physics and transform can work together?
When an object is affected by a force or being moved or translated, it’s transform (position, rotation, etc) is always updated.
What I suspect is happening in your case is that the force is applied (moving the object) and while these forces are still affecting the object, you alter the object’s position. Now since the object (Rigidbody) was affected by a force, it probably still has residual velocity and angular velocity which would cause the object to be jumpy.
When you want to move an object that contains a Rigidbody, it is best to use the Rigidbody specific functions like AddForce, AddTorque or rigidbody.movePosition or .moveRotation, etc…
If you want to move an object that does not contain a rigidbody, then altering the position, rotation, translation is fine.
If I remove the .position line, the object stays still no matter what forces I add. It is like transform.position and rigidbody.transform.position are separate. I notice that when I disable my character controller, the physics of my rigidbody work better, but I have no control over my character. Why hasn’t anyone invented a rigidbody character controller yet? Is that a good idea?
Long story short, Character Controller is supposed to create ‘unrealistic’ control. e.g. a character who runs very fast but can stop immediately(in real world you have to slow down until stop), so it can’t work well with Rigidbody. IMHO, it’s very weird to play as a Rigidbody, unless in a game like Ballance. So just use onControllerColliderHit on other objects and Character Controller on player.