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

Trying to understand CharacterController.Move

Discussion in 'Scripting' started by vincentellis, May 30, 2017.

  1. vincentellis

    vincentellis

    Joined:
    Oct 21, 2013
    Posts:
    100
    I'm using the CharacterController.Move function but i want to tweak a few things that i suspect it is doing. Unfortunately, i can't find the source code for it anywhere.

    https://docs.unity3d.com/ScriptReference/CharacterController.Move.html

    Does anyone know what exactly is this method doing? Is it Applying an impulse to the Rigidbody? Or is it applying a normal force?
     
  2. vincentellis

    vincentellis

    Joined:
    Oct 21, 2013
    Posts:
    100
  3. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,380
    There is no Rigidbody involved with CharacterController, it is an alternative to a RigidBody.

    Furthermore, it's actually a wrapper around the built in 'kinematic character controller' from PhysX (the physics engine used in unity):
    http://docs.nvidia.com/gameworks/co.../physx/guide/Manual/CharacterControllers.html

    This links goes over the general concept of how the character controller functions in the physics engine.

    There's NO forces. It just calculates if you can move the distance passed in to Move, and moves it. If there are things blocking, it will move around it in various simple ways... such as stepping and the sort.

    If you want to actually push things and have physics, you have to handle the OnControllerColliderHit event and push things yourself:
    https://docs.unity3d.com/ScriptReference/CharacterController.OnControllerColliderHit.html