16 lines
380 B
C#
16 lines
380 B
C#
using UnityEngine;
|
|
|
|
public class SwerveXSmoothMover : MonoBehaviour
|
|
{
|
|
public float smoothTime;
|
|
|
|
public float maxSpeed;
|
|
|
|
private float _currentXSpeed;
|
|
|
|
public void ApplyMove(ref Vector3 pos, float targetX, float speedRatio = 1f)
|
|
{
|
|
pos.x = Mathf.SmoothDamp(base.transform.localPosition.x, targetX, ref _currentXSpeed, smoothTime, maxSpeed * speedRatio, Time.deltaTime);
|
|
}
|
|
}
|