- Home /
Question by
EinfachFinn · Jan 16 at 03:10 PM ·
c#scripting problemainavmeshbeginner
NavMeshAgent, goes to the wrong place
Hey, I have this simple script here that tells my NavMeshAgent where to go. I have selected the "Target" prefab as shown in the first image. But as you can see in the second picture, the target ( I attached a red sphere to it for visualization) is not recognized as a destination, but only some dot in the sky. (the dashed line marks the way and the destination) What did I do wrong?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class EnemyNavMesh : MonoBehaviour {
[SerializeField] private Transform movePositionTransform;
private NavMeshAgent navMeshAgent;
private void Awake(){
navMeshAgent = GetComponent<NavMeshAgent>();
}
private void Update (){
navMeshAgent.destination = movePositionTransform.position;
}
}
unity-2.png
(27.3 kB)
unityvr-1.png
(153.8 kB)
Comment
Your answer
Follow this Question
Related Questions
How to reactivate items ? 4 Answers
How to get my navmeshagents to do certain things? 0 Answers
[Newbie] Particle System not playing, C# (unity 5.5) 3 Answers
State Machine Question 1 Answer
A Proper Way To Pause A Game 9 Answers