diff options
author | chai <215380520@qq.com> | 2023-05-05 10:11:50 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-05-05 10:11:50 +0800 |
commit | 81976db8c051ed7031fe3e3c2c4c41d4c149b2aa (patch) | |
tree | 04266bd9bd861d518a1a4d93b30b57105c9edef3 /marching/Assets/Scripts/Projectiles/BladeScript.cs | |
parent | 848097c88bbcf24934a375dff39cf4defa2819dd (diff) |
*misc
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); + } + } + } } |