0
\$\begingroup\$

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?

\$\endgroup\$
1
  • \$\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
    Commented Apr 22, 2020 at 14:47

1 Answer 1

2
\$\begingroup\$
  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.

\$\endgroup\$
2
  • \$\begingroup\$ Very helpful demonstration. Thanks! \$\endgroup\$ Commented Apr 23, 2020 at 12:50
  • \$\begingroup\$ How does CharacterController fit into this picture? \$\endgroup\$ Commented Apr 28, 2020 at 15:03

You must log in to answer this question.

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