blob: 402fa906e8203d31e7ee37c43f47a5a35b9f1ca2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
using UnityEngine;
public class RotSpring : MonoBehaviour
{
public bool x;
public bool y;
public bool z;
public float target;
public float spring;
public float damper;
private float currentValue;
private float vel;
private void Start()
{
if (x)
{
currentValue = base.transform.localEulerAngles.x;
}
else if (y)
{
currentValue = base.transform.localEulerAngles.y;
}
else if (z)
{
currentValue = base.transform.localEulerAngles.z;
}
}
private void Update()
{
vel = FRILerp.Lerp(vel, (target - currentValue) * spring, damper);
currentValue += vel * TimeHandler.deltaTime;
base.transform.localEulerAngles = new Vector3(x ? currentValue : 0f, y ? currentValue : 0f, z ? currentValue : 0f);
}
}
|