BITFALL/Assets/WSM Game Studio/Train Controller_v3/Shared/Scripts/SpeedChangeZone_v3.cs

26 lines
651 B
C#
Raw Normal View History

2024-03-22 20:16:32 +08:00
using UnityEngine;
using UnityEngine.Serialization;
namespace WSMGameStudio.RailroadSystem
{
public class SpeedChangeZone_v3 : MonoBehaviour
{
[FormerlySerializedAs("targetSpeed")]
[SerializeField] private float _targetSpeed = 65f;
public float TargetSpeed
{
get { return _targetSpeed; }
set { _targetSpeed = Mathf.Abs(value); }
}
private void OnTriggerEnter(Collider other)
{
ILocomotive locomotive = other.GetComponent<ILocomotive>();
if (locomotive != null)
locomotive.MaxSpeed = _targetSpeed;
}
}
}