Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
RigidLeaf.cs
Go to the documentation of this file.
1using UnityEngine;
2
3public class RigidLeaf : RigidUpdate
4{
5 public float floatPower = 0.6f;
6
7 public float slidePower = 15f;
8
9 private Vector2 v;
10
11 private float flip = 1f;
12
13 private float time;
14
15 private float maxTime;
16
17 private float f;
18
19 private float power = 1f;
20
21 private void Awake()
22 {
23 maxTime = Random.Range(0.5f, 1.5f);
24 }
25
26 public override void OnFixedUpdate()
27 {
28 _ = base.transform.position;
29 if (base.transform.position.y < 3f)
30 {
31 power -= Time.fixedDeltaTime * 0.03f;
32 }
33 else
34 {
35 power = 1f;
36 }
37 if (!(power < 0f))
38 {
39 time += flip * 0.01f;
40 if (time > maxTime)
41 {
42 maxTime = Random.Range(0.5f, 1.5f);
43 time = maxTime;
44 flip = -1f;
45 }
46 else if (time < 0f)
47 {
48 maxTime = Random.Range(0.5f, 1.5f);
49 time = 0f;
50 flip = 1f;
51 }
52 f = time - maxTime * 0.5f;
53 v.x = f * slidePower * power;
54 v.y = (10f - Mathf.Clamp(((f > 0f) ? f : (0f - f)) * 10f, 0f, 10f)) * floatPower * power;
55 rb.AddForce(v);
56 }
57 }
58}
float power
Definition: RigidLeaf.cs:19
float floatPower
Definition: RigidLeaf.cs:5
Vector2 v
Definition: RigidLeaf.cs:9
void Awake()
Definition: RigidLeaf.cs:21
float slidePower
Definition: RigidLeaf.cs:7
float flip
Definition: RigidLeaf.cs:11
float f
Definition: RigidLeaf.cs:17
float time
Definition: RigidLeaf.cs:13
override void OnFixedUpdate()
Definition: RigidLeaf.cs:26
float maxTime
Definition: RigidLeaf.cs:15
Rigidbody2D rb
Definition: RigidUpdate.cs:13