From 7b15dbb593df0ed4ac7618ed7b8bc8a9daad123b Mon Sep 17 00:00:00 2001 From: ProtoSharkk Date: Sun, 27 Oct 2024 21:27:38 -0700 Subject: [PATCH] Dashing into enemies creates a shockwave that pushes them away You don't take damage from this --- Assets/Scripts C#/Teo.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts C#/Teo.cs b/Assets/Scripts C#/Teo.cs index 32d3042..d88ea9a 100644 --- a/Assets/Scripts C#/Teo.cs +++ b/Assets/Scripts C#/Teo.cs @@ -94,9 +94,21 @@ public class Teo : MonoBehaviour ).normalized * dashDistance); // Wait 0.2 seconds before ending the dash yield return new WaitForSeconds(0.2F); - // Re enable collision and linearDamping after dash complete + // Re enable collision and linearDamping after dash dashing = false; - collider.enabled = true; controller.linearDamping = 15; + // Push enemies away at end of dash + foreach (Collider2D hit in Physics2D.OverlapCircleAll( + transform.position, 3 + )) { + if (hit.tag != "Ratbot") continue; + hit.GetComponent().AddRelativeForce( + (hit.transform.position - transform.position) + .normalized * dashDistance + ); + } + // Don't take damage at end of dash + yield return new WaitForSeconds(0.2F); + collider.enabled = true; } }