Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Character Controller Move( ) not behaving as expected

Discussion in 'Physics' started by ggama, Jun 4, 2021.

  1. ggama

    ggama

    Joined:
    Jun 4, 2021
    Posts:
    8
    Hey everyone,

    While implementing the gravity & jump on a character controller-based script, I stumbled across some weird fast jitter. I decided to isolate the problem and still can't understand why is this not behaving as expected

    In the following script I'm moving (accelerating) the character based on the Physics gravity value, theoretically shouldn't this behave exactly like a rigidbody with zero drag (while falling)?


    As you can see below (the capsule w/ the testMov script and the sphere w/ a zero drag rigidbody)


    If I use the characterController's velocity rather than my own velocity parameter the result becomes even faster.
    Finally I have tried hardcoding this speed factor to behave as expected (let's say 0.0065x the default gravity acceleration) and if I restart the editor or build the project this factor no longer behaves expected.

    Am I missing something trivial or is this a bug, if anyone could shed some light on the problem I would appreciate. :/


    (Tried on Unity 2020.3.ish)
     
  2. cwhelmi

    cwhelmi

    Joined:
    May 12, 2013
    Posts:
    6
    Unlike SimpleMove() which takes a velocity as an argument, CharacterController.Move() takes a distance. So you need to multiply by Time.deltaTime when you call it. Something like this:
    Code (CSharp):
    1. character.Move(velocity * Time.deltaTime);
    Hope that helps!