Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

[Navmesh] CharacterController and CapsuleCollider upwards direction

Discussion in '5.6 Beta' started by Nanity, Mar 1, 2017.

  1. Nanity

    Nanity

    Joined:
    Jul 6, 2012
    Posts:
    148
    You probably watched the KeyNote from GDC 2017. At minute 35:00 you see a Navmesh demo, where two planes are connected to each other by 90° and the agent rotates around 90°. Unfortunately I neither have worked with Navmesh nor do I have access to this demo, so I'm glad about every info someone can contribute.



    On the other hand, I've done some extensive prototyping with CharacterController and CapsuleCollider with variable gravitation directions. Both of them do not allow arbitrary orientations of the collider in space:

    CapsuleCollider Documentation

    Code (csharp):
    1. CapsuleCollider.direction
    2. The value can be 0, 1 or 2 corresponding to the X, Y and Z axes, respectively.
    The CharacterController on the other hand does not allow any orientation change.

    ----

    Suggestion A

    The CapsuleCollider/CharacterController will have the same absolute orientation as the transform they are part of. This means the direction property of CapsuleCollider should be removed. This means you'd have to nest 2 transforms in each other if you want to apply rotations without touching the base transform.

    Suggestion B

    Both get a Vector3 direction property that allow any arbitrary rotation of the component relative to the transform.

    ----

    Conclusion

    In both cases, the CharacterController would have to implement the UpDirection() methods from PhysX (case A private, case B public). Currently rotating the parent transform has no influence on the collider's orientation - it will always face upwards.

    With the new navmesh functionality coming around the corner, the CharacterController and CapsuleCollider should be prepared for any gravity direction and navmesh orientation.

    PhysX documentation

    Code (csharp):
    1. PxController::getUpDirection()
    2. PxController::setUpDirection()
     
    Last edited: Mar 1, 2017