blob: 47822f6444764d16a01dd9cdb94b25fbf29adcb4 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
using UnityEngine;
public class PlayerVelocity : MonoBehaviour
{
internal bool simulated = true;
internal bool isKinematic;
internal Vector2 velocity;
internal float mass = 100f;
internal float angularVelocity;
private CharacterData data;
public Vector2 position
{
get
{
return base.transform.position;
}
set
{
base.transform.position = value;
}
}
internal void AddTorque(float v)
{
}
private void Start()
{
data = GetComponent<CharacterData>();
}
private void FixedUpdate()
{
if (data.isPlaying)
{
if (isKinematic)
{
velocity *= 0f;
}
if (simulated && !isKinematic)
{
velocity += Vector2.down * Time.fixedDeltaTime * TimeHandler.timeScale * 20f;
base.transform.position += Time.fixedDeltaTime * TimeHandler.timeScale * (Vector3)velocity;
base.transform.position = new Vector3(base.transform.position.x, base.transform.position.y, 0f);
}
}
}
internal void AddForce(Vector2 force, ForceMode2D forceMode)
{
if (forceMode == ForceMode2D.Force)
{
force *= 0.02f;
}
else
{
force *= 1f;
}
velocity += force / mass;
}
internal void AddForce(Vector3 force, ForceMode2D forceMode)
{
AddForce((Vector2)force, forceMode);
}
internal void AddForce(Vector2 force)
{
AddForce(force, ForceMode2D.Force);
}
internal void AddForce(Vector3 force)
{
AddForce((Vector2)force, ForceMode2D.Force);
}
}
|