- Home /
 
 
               Question by 
               BlastOffProductions · Feb 06, 2020 at 03:37 AM · 
                aicharacternavmeshnavigation  
              
 
              How do I make my Nav Character Roll?
Basically I have made Nav Characters before, but I am trying something different. I'm not sure if it's possible with Unity's Nav System.
So I have a sphere (The AI), and I need him to move towards a moving target. I can make the AI move towards the moving character, but the AI doesn't roll towards the character. It looks very weird and un-natural. I tried changing the AI Controllers code, but it doesn't work with Unity AI System.
Is there anyway that anyone know of that could help? I'd Appreciate the help, this one has me stumped.
This is Unity's AI Character Controller Code:
 using System;
 using UnityEngine;
 
 namespace UnityStandardAssets.Characters.ThirdPerson
 {
     [RequireComponent(typeof (UnityEngine.AI.NavMeshAgent))]
     [RequireComponent(typeof (ThirdPersonCharacter))]
     public class AICharacterControl : MonoBehaviour
     {
         public UnityEngine.AI.NavMeshAgent agent { get; private set; }             // the navmesh agent required for the path finding
         public ThirdPersonCharacter character { get; private set; } // the character we are controlling
         public Transform target;                                    // target to aim for
 
 
         private void Start()
         {
             // get the components on the object we need ( should not be null due to require component so no need to check )
             agent = GetComponentInChildren<UnityEngine.AI.NavMeshAgent>();
             character = GetComponent<ThirdPersonCharacter>();
 
             agent.updateRotation = false;
             agent.updatePosition = true;
         }
 
 
         private void Update()
         {
             if (target != null)
                 agent.SetDestination(target.position);
 
             if (agent.remainingDistance > agent.stoppingDistance)
                 character.Move(agent.desiredVelocity, false, false);
             else
                 character.Move(Vector3.zero, false, false);
         }
 
 
         public void SetTarget(Transform target)
         {
             this.target = target;
         }
     }
 }
 
              
               Comment
              
 
               
              Your answer