У меня есть две ошибки: < /p>
Первая ошибка: < /p>
missomconconentexception: нет «Navmeshagent '». Вам, вероятно, нужно добавить Navmeshagent в игровой объект
"ThirdPersonController". Или ваш скрипт должен проверить, подключен ли компонент
перед его использованием. Patroll.cs < /p>
using UnityEngine;
using System.Collections;
public class Patroll : MonoBehaviour {
public Transform[] points;
private int destPoint = 0;
private NavMeshAgent agent;
// Use this for initialization
void Start () {
agent = GetComponent();
// Disabling auto-braking allows for continuous movement
// between points (ie, the agent doesn't slow down as it
// approaches a destination point).
agent.autoBraking = false;
GotoNextPoint();
}
void GotoNextPoint() {
// Returns if no points have been set up
if (points.Length == 0)
return;
// Set the agent to go to the currently selected destination.
agent.destination = points[destPoint].position;
// Choose the next point in the array as the destination,
// cycling to the start if necessary.
destPoint = (destPoint + 1) % points.Length;
}
void Update () {
// Choose the next destination point when the agent gets
// close to the current one.
if (agent.remainingDistance < 0.5f)
GotoNextPoint();
}
}
< /code>
строка 41 is: < /p>
if (agent.remainingDistance < 0.5f)
< /code>
This Script Patroll.cs Я перетащил в иерархию в ThirdPersonController. < /p>
Затем, после этого у меня есть еще одна ошибка, и эта ошибка, которую я также имел даже до того, как я создал скрипт patroll.cs: < /p>
был размещен на Navmesh.
UnityEngine.navmeshagent: get_remainingDistance ()
unitystandardassets.characters.thirdperson.aicharactercontrol: update ()
(at atsets /standard
Assets/символы/третья personcharacter/scripts/aicharactercontrol.cs: 31)
Эта ошибка находится в скрипте aicharactercontrol.cs. 31: < /p>
if (agent.remainingDistance > agent.stoppingDistance)
< /code>
То, что я пытался сделать до сих пор, чтобы исправить это в Unity. Я нажал на меню по компоненту> Навигации> Агент Navmesh < /p>
Теперь он добавлен в третий PersonController Агент NAV NESH, и я могу видеть в инспекторе третьего спектакля. Aicharactercontrol.cs script < /p>
using System;
using UnityEngine;
namespace UnityStandardAssets.Characters.ThirdPerson
{
[RequireComponent(typeof (NavMeshAgent))]
[RequireComponent(typeof (ThirdPersonCharacter))]
public class AICharacterControl : MonoBehaviour
{
public 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();
character = GetComponent();
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;
}
}
}
< /code>
Я не могу понять, как исправить ошибки. < /p>
Подробнее здесь: https://stackoverflow.com/questions/385 ... een-placed
GetRemainingDistance может быть вызван только активным агентом, который был помещен на Navmesh ⇐ C#
Место общения программистов C#
1759237440
Anonymous
У меня есть две ошибки: < /p>
Первая ошибка: < /p>
missomconconentexception: нет «Navmeshagent '». Вам, вероятно, нужно добавить Navmeshagent в игровой объект
"ThirdPersonController". Или ваш скрипт должен проверить, подключен ли компонент
перед его использованием. Patroll.cs < /p>
using UnityEngine;
using System.Collections;
public class Patroll : MonoBehaviour {
public Transform[] points;
private int destPoint = 0;
private NavMeshAgent agent;
// Use this for initialization
void Start () {
agent = GetComponent();
// Disabling auto-braking allows for continuous movement
// between points (ie, the agent doesn't slow down as it
// approaches a destination point).
agent.autoBraking = false;
GotoNextPoint();
}
void GotoNextPoint() {
// Returns if no points have been set up
if (points.Length == 0)
return;
// Set the agent to go to the currently selected destination.
agent.destination = points[destPoint].position;
// Choose the next point in the array as the destination,
// cycling to the start if necessary.
destPoint = (destPoint + 1) % points.Length;
}
void Update () {
// Choose the next destination point when the agent gets
// close to the current one.
if (agent.remainingDistance < 0.5f)
GotoNextPoint();
}
}
< /code>
строка 41 is: < /p>
if (agent.remainingDistance < 0.5f)
< /code>
This Script Patroll.cs Я перетащил в иерархию в ThirdPersonController. < /p>
Затем, после этого у меня есть еще одна ошибка, и эта ошибка, которую я также имел даже до того, как я создал скрипт patroll.cs: < /p>
был размещен на Navmesh.
UnityEngine.navmeshagent: get_remainingDistance ()
unitystandardassets.characters.thirdperson.aicharactercontrol: update ()
(at atsets /standard
Assets/символы/третья personcharacter/scripts/aicharactercontrol.cs: 31)
Эта ошибка находится в скрипте aicharactercontrol.cs. 31: < /p>
if (agent.remainingDistance > agent.stoppingDistance)
< /code>
То, что я пытался сделать до сих пор, чтобы исправить это в Unity. Я нажал на меню по компоненту> Навигации> Агент Navmesh < /p>
Теперь он добавлен в третий PersonController Агент NAV NESH, и я могу видеть в инспекторе третьего спектакля. Aicharactercontrol.cs script < /p>
using System;
using UnityEngine;
namespace UnityStandardAssets.Characters.ThirdPerson
{
[RequireComponent(typeof (NavMeshAgent))]
[RequireComponent(typeof (ThirdPersonCharacter))]
public class AICharacterControl : MonoBehaviour
{
public 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();
character = GetComponent();
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;
}
}
}
< /code>
Я не могу понять, как исправить ошибки. < /p>
Подробнее здесь: [url]https://stackoverflow.com/questions/38537282/getremainingdistance-can-only-be-called-on-an-active-agent-that-has-been-placed[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия