- Home /
How to make AICharacterController able to walk on walls and ceilings?
Now that we have new NavMesh components I wanted my character to be able to climb walls and ceilings (just planes oriented at 90 and 180 degress). I can do that with simple objects, 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, but once character gets to the wall it acts weird. How can I make this particular AICharacterController able to walk normally on walls and ceilings and in any orientation?
Gravity on: Character pulled down to the lower edge of NavMesh, can't move up.
Gravity off: 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? I've tried to add force pointing down from character model but it still didn't help. 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:
private void Update()
{
// My addition
if (Input.GetMouseButtonDown(0) && !Input.GetKey(KeyCode.LeftShift))
{
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray.origin, ray.direction, out m_HitInfo)){
agent.destination = m_HitInfo.point;
//target = m_HitInfo.transform;
}
}
if (target != null) {
agent.SetDestination (target.position);
}
//My addition
agent.SetDestination(m_HitInfo.point);
if (agent.remainingDistance > agent.stoppingDistance)
character.Move(agent.desiredVelocity, false, false);
else
character.Move(Vector3.zero, false, false);
}
Your answer
Follow this Question
Related Questions
Connecting two navmeshes without "Speedboost" 0 Answers
NavMeshAgent doesn't face to it's destination in close distance! 1 Answer
How can i modify the navMesh path? 0 Answers
NavMesh Agent not updating (Setting) new path 1 Answer
is it possible to use navmesh on flying character and target ? 0 Answers