Answer the question
In order to leave comments, you need to log in
Need help what to do if error CS1061 appears?
Assets/�⠭����/Standard Assets/Characters/ThirdPersonCharacter/Scripts/AICharacterControl.cs(33,27): error CS1061: Type `UnityEngine.AI.NavMeshAgent' does not contain a definition for `remainigDistance' and no extension method `remainigDistance' of type `UnityEngine.AI.NavMeshAgent' could be found. Are you missing an assembly reference?
Here is the script:
using System;
using UnityEngine;
namespace UnityStandardAssets.Characters.ThirdPerson
{
[RequireComponent(typeof (UnityEngine.AI.NavMeshAgent))]
[RequireComponent(typeof (ThirdPersonCharacter))]
public class AICharacterControl : MonoBehavior
{
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
public float maxDistance;
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();
character = GetComponent();
agent.updateRotation = false;
agent.updatePosition = true;
}
// Update is called once per frame
private void Update()
{
if (target != null)
if (maxDistance > (Vector3.Distance(target.position, transform.position)))
agent.SetDestination(target.position);
if (agent.remainigDistance > agent.stoppingDistance)
character.Move(agent.desiredVelocity, false, false);
else
character.Move(Vector3.zero, false, false);
}
public void SetTarget(Transform target)
{
this.target = target;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question