init
This commit is contained in:
commit
341a877b4a
2338 changed files with 1346408 additions and 0 deletions
23
Assets/NavMesh/Examples/Scripts/RandomWalk.cs
Normal file
23
Assets/NavMesh/Examples/Scripts/RandomWalk.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
// Walk to a random position and repeat
|
||||
[RequireComponent(typeof(NavMeshAgent))]
|
||||
public class RandomWalk : MonoBehaviour
|
||||
{
|
||||
public float m_Range = 25.0f;
|
||||
NavMeshAgent m_Agent;
|
||||
|
||||
void Start()
|
||||
{
|
||||
m_Agent = GetComponent<NavMeshAgent>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (m_Agent.pathPending || m_Agent.remainingDistance > 0.1f)
|
||||
return;
|
||||
|
||||
m_Agent.destination = m_Range * Random.insideUnitCircle;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue