final (i hope)
This commit is contained in:
1 parent
3c6679ab04
commit
db18247040
6 files changed
+816
-59
No files matched your search
@@ -4,12 +4,14 @@ namespace Code.Gameplay
|
||||
{
|
||||
public class AICarController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float speed = 15f;
|
||||
[SerializeField] public float speed = 15f;
|
||||
[SerializeField] private float stoppingDistance = 2f;
|
||||
[SerializeField] private float turnSpeed = 3f;
|
||||
|
||||
private Vector3[] _waypoints;
|
||||
private int _currentWaypointIndex;
|
||||
|
||||
private bool _isStopped;
|
||||
|
||||
public void SetRoute(Vector3[] waypoints)
|
||||
{
|
||||
@@ -19,7 +21,14 @@ namespace Code.Gameplay
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_waypoints == null || _waypoints.Length == 0) return;
|
||||
if (_waypoints == null || _waypoints.Length == 0 || _isStopped) return;
|
||||
|
||||
if (_currentWaypointIndex >= _waypoints.Length - 1)
|
||||
{
|
||||
var raceManager = FindFirstObjectByType<RaceManager>();
|
||||
raceManager?.OnLoose();
|
||||
_isStopped = true;
|
||||
}
|
||||
|
||||
var target = _waypoints[_currentWaypointIndex];
|
||||
var direction = target - transform.position;
|
||||
|
||||
Reference in new issue
Block a user