diff options
Diffstat (limited to 'marching/Assets/Scripts/Projectiles/BladeScript.cs')
-rw-r--r-- | marching/Assets/Scripts/Projectiles/BladeScript.cs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/marching/Assets/Scripts/Projectiles/BladeScript.cs b/marching/Assets/Scripts/Projectiles/BladeScript.cs index f5f613c..8a71c27 100644 --- a/marching/Assets/Scripts/Projectiles/BladeScript.cs +++ b/marching/Assets/Scripts/Projectiles/BladeScript.cs @@ -1,3 +1,4 @@ +using MH; using System; using System.Collections; using System.Collections.Generic; @@ -38,4 +39,24 @@ public class BladeScript : ProjectileBase sr.flipX = flip; } + private void OnTriggerEnter2D(Collider2D other) + { + Debug.Log(other.gameObject.name); + LayerMask layerMask = LayerMask.GetMask("Hurtbox"); + if ((layerMask & (1 << other.transform.gameObject.layer)) != 0) + { + //Debug.Log(other.GetType().Name); + Rigidbody2D rig = other.transform.parent.GetComponent<Rigidbody2D>(); + if(rig != null) + { + Debug.Log("force"); + UnitBase hero = UnitManager.hero; + Vector2 pos = transform.position; + Vector2 heroPos = hero.transform.position; + Vector2 dir = (heroPos - pos).normalized; + + rig.AddForce(-dir * 100); + } + } + } } |