From 3f558125335a81affeaddc4d49c4769e5329f826 Mon Sep 17 00:00:00 2001 From: Saibotk Date: Tue, 24 Apr 2018 06:11:31 +0200 Subject: [PATCH] draw debug door vector --- Assets/Scripts/Door.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Door.cs b/Assets/Scripts/Door.cs index e490b57..246faa9 100644 --- a/Assets/Scripts/Door.cs +++ b/Assets/Scripts/Door.cs @@ -69,6 +69,10 @@ public class Door : MonoBehaviour { return locked; } + private void Update() { + Debug.DrawLine(gameObject.transform.position, gameObject.transform.position + new Vector3(toOuter.x, toOuter.y, 0)); + } + /// /// Check if a player moved inside of a room and notify the room. /// @@ -79,7 +83,8 @@ 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(); - float angle = Vector2.Angle(( centerToPlayer - centerToCollider ), toOuter); + float angle = Vector2.Angle(toOuter, ( centerToPlayer - centerToCollider )); + if ( (angle > 90 && angle < 270) ) { Debug.Log("Player is on the outside! Angle: " + angle); return;