I am studying Unity, and so far I encountered three different ways to move a character. As far as I understand:

  • Directly changing the transform - ignores both physics and colliders;
  • Using a CharacterController component - ignores physics but considers colliders;
  • Using a RigidBody component - considers both physics and colliders.

Are these descriptions correct? Which one should I use?

  • \$\begingroup\$ "List some famous games" is NOT a good way to decide what's right for your game, and is not on-topic here. What kind of game are you making, how have you tried applying these solutions to it so far, and how do the results differ from what you need for your game? \$\endgroup\$ – DMGregory Apr 22 at 14:47
  1. Changing the transform ignores colliders at that moment, but for clarity you should mention that this does not mean that it won't have any physical effect at all. When the physics engine does its next update after the transform manipulation resulted in two overlapping rigidbodies, then it will try to push those two colliders apart. Personally I like the distinction: "changing the position doesn't move an object, it teleports an object".
  2. The distinction between rigidbody and transform is not so simple. There are many ways to use the rigidbody component which are worth examining in detail because they have subtle differences:
    • Changing rigidbody.position which is not much different from changing transform.position
    • Changing rigidbody.velocity
    • Using the rigidbody.MovePosition method
    • Using the rigidbody.AddForce method

A while ago I created a little demo where you can try out different movement methods and see their side-effects for yourself.

| improve this answer | |
  • \$\begingroup\$ Very helpful demonstration. Thanks! \$\endgroup\$ – Erel Segal-Halevi Apr 23 at 12:50
  • \$\begingroup\$ How does CharacterController fit into this picture? \$\endgroup\$ – Erel Segal-Halevi Apr 28 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.