blob: 6d05434bfa10fc66d0d57c5b8d873bd50974d3f3 (
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
|
using UnityEngine;
public class PlayerWobblePosition : MonoBehaviour
{
private Vector3 physicsPos;
public float drag = 15f;
public float spring = 1000f;
public float multiplier = 1f;
public float prediction;
private Vector3 velocity;
private Player player;
private void Start()
{
physicsPos = base.transform.position;
player = GetComponentInParent<Player>();
}
private void Update()
{
float num = Mathf.Clamp(TimeHandler.deltaTime, 0f, 0.03f);
Vector3 position = player.transform.position;
if (prediction > 0f)
{
position += (Vector3)player.data.playerVel.velocity * prediction;
}
velocity += (position - physicsPos) * num * spring;
velocity -= velocity * drag * num;
physicsPos += num * multiplier * velocity;
base.transform.position = physicsPos;
}
}
|