Развитие гоночек
This commit is contained in:
1 parent
ec60c47652
commit
b54083521f
532 files changed
+16091
-28231
No files matched your search
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
namespace Code.Example.Race.Racer.AI
|
||||
{
|
||||
public class AIRacer : Racer
|
||||
{
|
||||
[SerializeField] private NavMeshAgent navMeshAgent;
|
||||
|
||||
public override void SetData(RacerData data)
|
||||
{
|
||||
Data = data;
|
||||
navMeshAgent.angularSpeed = data.angularSpeed;
|
||||
navMeshAgent.speed = data.speed;
|
||||
}
|
||||
|
||||
public override void Initialize(List<Transform> waypoints)
|
||||
{
|
||||
navMeshAgent.isStopped = true;
|
||||
|
||||
Waypoints = waypoints;
|
||||
navMeshAgent.destination = Waypoints[CurrentWaypointIndex].position;
|
||||
|
||||
CurrentWaypointIndex++;
|
||||
}
|
||||
public override void StartRacer() => navMeshAgent.isStopped = false;
|
||||
public override void StopRacer() => navMeshAgent.isStopped = true;
|
||||
public override void NextWaypoint()
|
||||
{
|
||||
if(CurrentWaypointIndex >= Waypoints.Count) CurrentWaypointIndex = 0;
|
||||
|
||||
navMeshAgent.destination = Waypoints[CurrentWaypointIndex++].position;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user