You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.5 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public enum DriveState
{
Line = 0,
Turn,
PointOver,
Stop,
}
public class Drive : MonoBehaviour
{
public bool isnormalDrive = true;
public bool isStop = false;
public DriveState dirveState = DriveState.Line;
public float drivetime = 0;
public float checktime = 0;
public Vector3 driveDir;
public int carId = 0;
public GameObject FrontCar=null;
public NavMeshAgent agent;
public Transform dir_trans = null;//检测路径点用
private void FixedUpdate()
{
if (!isStop)
{
if (agent != null)
{
switch (dirveState)
{
case DriveState.Stop:
//agent.speed = 0;
//agent.velocity = Vector3.zero;
break;
case DriveState.PointOver:
agent.speed = 0;
agent.velocity = driveDir * 5;
break;
case DriveState.Turn:
agent.speed = 20;
agent.velocity = driveDir * 15;
break;
case DriveState.Line:
agent.speed = 20;
agent.velocity = driveDir * 20;
break;
}
}
}
}
}