diff --git a/Assets/Scripts/Door.cs b/Assets/Scripts/Door.cs index 246faa9..398979c 100644 --- a/Assets/Scripts/Door.cs +++ b/Assets/Scripts/Door.cs @@ -71,6 +71,8 @@ public class Door : MonoBehaviour { private void Update() { Debug.DrawLine(gameObject.transform.position, gameObject.transform.position + new Vector3(toOuter.x, toOuter.y, 0)); + Debug.DrawLine(new Vector3(), ( Vector2 ) ( parent.GetCenter() )); + Debug.DrawLine((Vector2)parent.GetCenter(), ( gameObject.transform.position )); } /// @@ -81,14 +83,15 @@ public class Door : MonoBehaviour { // TODO only works correct for entering a room! if ( collision.tag == "Player") { 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(); + Vector2 centerToCollider = (Vector2) gameObject.transform.position - parent.GetCenter(); + Vector2 centerToPlayer = (Vector2) player.gameObject.transform.position - parent.GetCenter(); float angle = Vector2.Angle(toOuter, ( centerToPlayer - centerToCollider )); - if ( (angle > 90 && angle < 270) ) { + if ( (angle > 90 && angle < 270) && (centerToPlayer - centerToCollider).magnitude < 1) { Debug.Log("Player is on the outside! Angle: " + angle); return; } + Debug.Log("magn: " + ( centerToPlayer - centerToCollider ).magnitude); Debug.Log("Leaving Trigger"); if(parent == null) { Debug.Log("This door has no parent Room!"); diff --git a/Assets/Scripts/Generation/DungeonGenerator.cs b/Assets/Scripts/Generation/DungeonGenerator.cs index a79bad1..1bf1eb6 100644 --- a/Assets/Scripts/Generation/DungeonGenerator.cs +++ b/Assets/Scripts/Generation/DungeonGenerator.cs @@ -453,7 +453,7 @@ public class DungeonGenerator { } } } - Debug.Log(r.GetCenter() + " " + r.spawnpoints.Count + " spawn points."); + //Debug.Log(r.GetCenter() + " " + r.spawnpoints.Count + " spawn points."); } public static void GenerateObjective(Room r) {