Search Unity

Internal Character Controller Source Code

Discussion in 'Scripting' started by droni, Jan 8, 2020.

Thread Status:
Not open for further replies.
  1. droni

    droni

    Joined:
    Jul 25, 2014
    Posts:
    10
    Well I am curious if there is a possibility to get hands on the source code of the Character Controller, I want to see how it works, in order to learn it and create my own depending on rigidbody.

    Is there any way to get your hands on the code

    Greetings Phil
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Here's what is available publicly, which doesn't appear to be much. The fairly scant source code on the C# side, and the CharacterController.h file, tells me much of this component is implemented on the C side, though I've not really looked through the Unity managed source code before. But you can take a look below yourself.

    https://github.com/Unity-Technologi...cterController&unscoped_q=CharacterController
     
    droni likes this.
  3. droni

    droni

    Joined:
    Jul 25, 2014
    Posts:
    10
    I have no problem with reading c, but I tried to replace the character controller and run into some issues is there maybe some tutorial that will teach me how to implement such a system properly?
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The reading c part isn't the issue. Unity only publishes the managed, C#, side of the engine source code. You'd need to enter into an agreement with Unity in order to get access to anything more.
     
    droni likes this.
  5. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,537
    the CharacterController class is a wrapper around the PhysX character controller extensions. Basically this:
    https://docs.nvidia.com/gameworks/c.../physx/guide/Manual/CharacterControllers.html

    The source actually isn't even Unity's, and is from Nvidia/PhysX.

    Sadly, Unity also gimps the character controller massively (for example physx supports numerous shapes, not just capsule. And it also supports arbitrary up-axis, not just x,y,or z).

    Implementing it yourself is well... not going to be that easy. Considering that it's all tapping into the PhysX api, and Unity does not give you direct access to the PhysX api.
     
    Seith, spark-man, droni and 1 other person like this.
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    Instead of starting from Unity's CC, you could look for other rigidbody-based FPV or 3PV character controllers on the net, find one that sorta does what you want and go from there...
     
    droni likes this.
  7. droni

    droni

    Joined:
    Jul 25, 2014
    Posts:
    10
    Yes I just already used some functionallity from the Character controller in my FPSController, which uses these functions. Probably will do this.

    btw thanks for the PhysX Manual I think this would help me understand some systems implemented as the Stepping
     
Thread Status:
Not open for further replies.