blob: 1d9cb83bf8439a4fdafbd67b9bed8984ea5034eb (
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
|
using UnityEngine;
public class Gravity : MonoBehaviour
{
public float gravityForce;
public float exponent = 1f;
private PlayerVelocity rig;
private CharacterData data;
private void Start()
{
data = GetComponent<CharacterData>();
rig = GetComponent<PlayerVelocity>();
}
private void FixedUpdate()
{
float num = data.sinceGrounded;
if (data.sinceWallGrab < num)
{
num = data.sinceWallGrab;
}
if (num > 0f)
{
rig.AddForce(Vector3.down * TimeHandler.timeScale * Mathf.Pow(num, exponent) * gravityForce * rig.mass, ForceMode2D.Force);
}
else
{
rig.AddForce(Vector3.down * TimeHandler.timeScale * num * gravityForce * rig.mass, ForceMode2D.Force);
}
}
}
|