18 lines
520 B
C#
18 lines
520 B
C#
|
|
using UnityEngine;
|
|
|
|
public class SimpleLaneFollowingBehavior : ICarBehavior
|
|
{
|
|
|
|
public static readonly SimpleLaneFollowingBehavior Instance = new SimpleLaneFollowingBehavior();
|
|
|
|
public void UpdateBehavior(TrafficCar car)
|
|
{
|
|
car.transform.Translate(Vector3.forward * car.forwardSpeed * Time.deltaTime);
|
|
|
|
Vector3 newPos = car.transform.position;
|
|
newPos.x = Mathf.Lerp(newPos.x, car.TargetX, Time.deltaTime * car.laneChangeSpeed);
|
|
car.transform.position = newPos;
|
|
}
|
|
}
|