OvertakingLegend/Assets/Amazing Assets/Curved World/Example Scenes/Files/Scripts/WalkingAround.cs

30 lines
800 B
C#
Raw Permalink Normal View History

2025-03-24 03:08:22 +00:00
// Curved World <http://u3d.as/1W8h>
// Copyright (c) Amazing Assets <https://amazingassets.world>
using UnityEngine;
using UnityEngine.AI;
namespace AmazingAssets.CurvedWorld.Examples
{
public class WalkingAround : MonoBehaviour
{
public Vector2 xMinMaxRange;
public Vector2 zMinMaxRange;
NavMeshAgent agent;
// Use this for initialization
void Start()
{
agent = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void FixedUpdate()
{
if (agent.velocity.magnitude < 0.5f)
agent.SetDestination(new Vector3(Random.Range(xMinMaxRange.x, xMinMaxRange.y), 0, Random.Range(zMinMaxRange.x, zMinMaxRange.y)));
}
}
}