30 lines
870 B
C#
30 lines
870 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
namespace BITKit.FPS
|
|
{
|
|
[Serializable]
|
|
public class Spring3
|
|
{
|
|
public Vector3 value = Vector2.zero;
|
|
[SerializeField] private Vector3 dampValue = Vector2.zero;
|
|
[SerializeField] private float damp = 1;
|
|
[SerializeField] private float frequence = 1;
|
|
public void Clear()
|
|
{
|
|
value = Vector2.zero;
|
|
dampValue = Vector2.zero;
|
|
}
|
|
public Spring3(float damp, float frequence)
|
|
{
|
|
this.damp = damp;
|
|
this.frequence = frequence;
|
|
}
|
|
public void Update(float deltaTime, Vector3 target)
|
|
{
|
|
value -= dampValue * deltaTime * frequence;
|
|
dampValue = Vector3.Lerp(dampValue, value - target, deltaTime * damp);
|
|
}
|
|
}
|
|
} |