summaryrefslogtreecommitdiff
path: root/GameCode/RunSmoke.cs
diff options
context:
space:
mode:
Diffstat (limited to 'GameCode/RunSmoke.cs')
-rw-r--r--GameCode/RunSmoke.cs62
1 files changed, 62 insertions, 0 deletions
diff --git a/GameCode/RunSmoke.cs b/GameCode/RunSmoke.cs
new file mode 100644
index 0000000..6e45d62
--- /dev/null
+++ b/GameCode/RunSmoke.cs
@@ -0,0 +1,62 @@
+using UnityEngine;
+
+public class RunSmoke : MonoBehaviour
+{
+ private CharacterData data;
+
+ private ParticleSystem part;
+
+ private float c;
+
+ private bool groundedLastFrame;
+
+ private ParticleSystem.MainModule partVel;
+
+ private bool didTryToEmit;
+
+ private Vector3 vel;
+
+ private void Start()
+ {
+ part = GetComponent<ParticleSystem>();
+ data = GetComponentInParent<CharacterData>();
+ partVel = part.main;
+ }
+
+ private void Update()
+ {
+ didTryToEmit = false;
+ if (data.isGrounded && Mathf.Abs(data.playerVel.velocity.x) > 5f)
+ {
+ base.transform.position = new Vector3(data.transform.position.x, data.groundPos.y, 5f);
+ Go();
+ }
+ else if (data.isWallGrab && data.wallDistance < 0.7f && data.playerVel.velocity.magnitude > 5f)
+ {
+ base.transform.position = new Vector3(data.wallPos.x, data.transform.position.y, 5f);
+ Go();
+ }
+ if (didTryToEmit)
+ {
+ vel = Vector3.Lerp(vel, data.playerVel.velocity, TimeHandler.deltaTime * 2f);
+ }
+ else
+ {
+ vel = Vector3.Lerp(vel, Vector3.zero, TimeHandler.deltaTime * 10f);
+ }
+ }
+
+ private void Go()
+ {
+ didTryToEmit = true;
+ c += TimeHandler.deltaTime;
+ if (c > 0.02f)
+ {
+ c = 0f;
+ float num = 2f;
+ part.transform.rotation = Quaternion.LookRotation(vel);
+ partVel.startSpeedMultiplier = data.playerVel.velocity.magnitude * num;
+ part.Emit(2);
+ }
+ }
+}