From e3eefc901ca58daf1d6ba628ef5bcf811915e5a9 Mon Sep 17 00:00:00 2001 From: Saibotk Date: Tue, 24 Apr 2018 06:02:41 +0200 Subject: [PATCH] WIP door detection --- Assets/Scripts/Door.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Door.cs b/Assets/Scripts/Door.cs index 4404ad3..e490b57 100644 --- a/Assets/Scripts/Door.cs +++ b/Assets/Scripts/Door.cs @@ -79,13 +79,11 @@ public class Door : MonoBehaviour { Player player = collision.gameObject.GetComponent(); Vector2 centerToCollider = (Vector2) gameObject.transform.position - parent.GetPosition() + parent.GetCenter(); Vector2 centerToPlayer = (Vector2) player.gameObject.transform.position - parent.GetPosition() + parent.GetCenter(); - if (centerToCollider.magnitude - 0.89 < centerToPlayer.magnitude) { - Debug.Log(centerToCollider.magnitude - 0.89); - Debug.Log(centerToPlayer.magnitude); + float angle = Vector2.Angle(( centerToPlayer - centerToCollider ), toOuter); + if ( (angle > 90 && angle < 270) ) { + Debug.Log("Player is on the outside! Angle: " + angle); return; } - Debug.Log(centerToCollider.magnitude - 0.89); - Debug.Log(centerToPlayer.magnitude); Debug.Log("Leaving Trigger"); if(parent == null) { Debug.Log("This door has no parent Room!");