stighy
stighy

Reputation: 7170

Unity: How to move a player using Character controller in step?

I would like to move my Player in "block" of 0.1 unity unit (or 1).

How to modify / configure Character controller to move with "fixed" step?

Upvotes: 4

Views: 3407

Answers (2)

ZzAtomiic
ZzAtomiic

Reputation: 326

If you want to use the Character Controller component to move your object, you would want to use its dedicated methods:

  1. Move
  2. SimpleMove

Also, there's some difference between the 2 methods stated above.
The Move method is more complex and performance wise. As it takes care of complex physics such as gravity, collisions and will move the object by motion.
The SimpleMove method, instead, is more lightweight because it will only move the object without taking care of environmental physics.

If you want to move by a single unit, probably the code should look something like this:

//Controller being your character controller component
Controller.SimpleMove(Vector3.forward);

Upvotes: 3

Deekshith Hegde
Deekshith Hegde

Reputation: 1538

You can use transform.Translate to move the character

    //moves the character 1 unit in x direction
    transform.Translate(1.0f, 0.0f, 0.0f);

Upvotes: 3

Related Questions