Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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,514
    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