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
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Convert Standard Assets AICharacterController for Walls/Ceilings

Discussion in 'AI & Navigation Previews' started by Sarrivin, Apr 3, 2017.

  1. Sarrivin


    Dec 18, 2015

    The new NavMesh components are great. But I've run into such issue - I can make a cyllinder climb wall and ceilings (just planes oriented at 90 and 180 degress), but when I use AICharacterController from Unity Standard Assets it cannot move properly, probably because of physics.
    I've used NavMeshLinks for moving from surface to surface properly.

    Gravity on:
    Zrzut ekranu 2017-04-03 o 18.17.32.png Zrzut ekranu 2017-04-03 o 18.17.40.png
    Character pulled down to the lower edge of NavMesh, can't move up.
    Gravity off:
    Zrzut ekranu 2017-04-03 o 18.16.44.png Zrzut ekranu 2017-04-03 o 18.16.38.png
    Character moving very slowly and jittery, moves legs, sometimes "flies".

    How to make AICharacterController controller (Ethan) able to move on walls and ceilings with physics normally, just different "ground" (and gravity) orientation?
    I've tried to add force pointing down to character model but it still didn't help. AI character controller doesn't move properly even when gravity is disabled in his Rigidbody component. He either moves very slow, or doesn't move his legs, or falls down, etc.

    I've added this code for "click to move" in Update() of AICharacterControl:
    Code (CSharp):
    1.        private void Update()
    2.         {
    3.             // My addition
    4.             if (Input.GetMouseButtonDown(0) && !Input.GetKey(KeyCode.LeftShift))
    5.             {
    6.                 var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    7.                 if (Physics.Raycast(ray.origin, ray.direction, out m_HitInfo)){
    8.                     agent.destination = m_HitInfo.point;
    9.                     //target = m_HitInfo.transform;
    10.                 }
    11.             }
    13.             if (target != null) {
    14.                 agent.SetDestination (target.position);
    15.             }
    17.             //My addition
    18.             agent.SetDestination(m_HitInfo.point);
    20.             if (agent.remainingDistance > agent.stoppingDistance)
    21.                 character.Move(agent.desiredVelocity, false, false);
    22.             else
    23.                 character.Move(, false, false);
    24.         }
    Is there some simple way to fix it?
    I'd appreciate any help.

    PS. A request to Unity team - could you please update the AICharacterController for differently oriented surfaces now that they're part of the engine?