Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
RigidFloat.cs
Go to the documentation of this file.
1using UnityEngine;
2
3public class RigidFloat : RigidUpdate
4{
5 public float airHeight = 3.5f;
6
7 public float floatPower = 30f;
8
9 public float pingpongTime = 1f;
10
11 public float pingpongPower = 0.15f;
12
13 private float _airHeight;
14
15 private float time;
16
17 private float flip = 1f;
18
19 private void Awake()
20 {
21 _airHeight = airHeight + Random.Range(-2f, 2f);
22 time = Random.Range(0f, pingpongTime);
23 }
24
25 public override void OnFixedUpdate()
26 {
27 time += Time.fixedDeltaTime * flip;
28 if (time > pingpongTime)
29 {
30 flip = -1f;
32 }
33 else if (time < 0f)
34 {
35 flip = 1f;
36 time = 0f;
37 }
38 float num = time - pingpongTime * 0.5f;
39 num = ((!(num > 0f)) ? (Mathf.Sqrt(0f - num) * -1f) : Mathf.Sqrt(num));
40 float num2 = _airHeight + num * pingpongPower;
41 float num3 = base.transform.position.y;
42 if (num3 < num2)
43 {
44 if (num3 < 1f)
45 {
46 num3 = 1f;
47 }
48 rb.AddForce(new Vector2(0f, floatPower * (1f - num3 / num2)));
49 }
50 }
51}
float flip
Definition: RigidFloat.cs:17
void Awake()
Definition: RigidFloat.cs:19
float pingpongPower
Definition: RigidFloat.cs:11
override void OnFixedUpdate()
Definition: RigidFloat.cs:25
float time
Definition: RigidFloat.cs:15
float airHeight
Definition: RigidFloat.cs:5
float floatPower
Definition: RigidFloat.cs:7
float pingpongTime
Definition: RigidFloat.cs:9
float _airHeight
Definition: RigidFloat.cs:13
Rigidbody2D rb
Definition: RigidUpdate.cs:13