diff --git a/Assets/Scripts/Door.cs b/Assets/Scripts/Door.cs index 3fce817..7ab0529 100644 --- a/Assets/Scripts/Door.cs +++ b/Assets/Scripts/Door.cs @@ -70,11 +70,11 @@ public class Door : MonoBehaviour { } private void Update() { - Player player = GameController.instance.GetPlayer(); - Debug.DrawLine(gameObject.transform.position, gameObject.transform.position + new Vector3(toOuter.x, toOuter.y, 0)); + //Player player = GameController.instance.GetPlayer(); + //Debug.DrawLine(gameObject.transform.position, gameObject.transform.position + new Vector3(toOuter.x, toOuter.y, 0)); //Debug.DrawLine(new Vector3(), ( Vector2 ) ( parent.GetCenter() )); - Debug.DrawLine(player.gameObject.transform.position, gameObject.transform.position); - Debug.DrawLine((Vector2)parent.GetCenter(), ( gameObject.transform.position )); + //Debug.DrawLine(player.gameObject.transform.position, gameObject.transform.position); + //Debug.DrawLine((Vector2)parent.GetCenter(), ( gameObject.transform.position )); } /// @@ -85,10 +85,10 @@ public class Door : MonoBehaviour { // TODO only works correct for entering a room! if ( collision.tag == "Player") { Player player = collision.gameObject.GetComponent(); - Vector3 colliderToPlayer = player.gameObject.transform.position - gameObject.transform.position; - float angle = Vector2.Angle(toOuter, player.gameObject.transform.position - gameObject.transform.position); + Vector3 colliderToPlayer = player.gameObject.transform.position - ( gameObject.transform.position - (Vector3) (0.6f * (Vector2) toOuter)); + float angle = Vector2.Angle(toOuter, colliderToPlayer); - if ( (angle > 90) && colliderToPlayer.magnitude < 1) { + if ( angle < 90) { Debug.Log("Player is on the outside! Angle: " + angle); return; } diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index eddd1a3..e421d6e 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -386,8 +386,4 @@ public class GameController : MonoBehaviour { public void Continue() { ChangeState(GameState.RUNNING); } - - public Player GetPlayer() { - return player; - } }