Skip to content

Commit 1a555e1

Browse files
authored
add NavMeshAgentExample.cs
1 parent e12d361 commit 1a555e1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// made with chatGPT
2+
3+
using UnityEngine;
4+
using UnityEngine.AI;
5+
6+
namespace UnityLibrary
7+
{
8+
public class NavMeshAgentExample : MonoBehaviour
9+
{
10+
public Transform target;
11+
12+
private NavMeshAgent agent;
13+
14+
void Start()
15+
{
16+
// Get the NavMeshAgent component on this game object
17+
agent = GetComponent<NavMeshAgent>();
18+
19+
// Set the destination of the NavMeshAgent to the target Transform
20+
agent.destination = target.position;
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)