1
0
Fork 0

WIP door detection

This commit is contained in:
Saibotk 2018-04-24 06:02:41 +02:00
parent e49d5d2ea4
commit e3eefc901c

View file

@ -79,13 +79,11 @@ public class Door : MonoBehaviour {
Player player = collision.gameObject.GetComponent<Player>(); Player player = collision.gameObject.GetComponent<Player>();
Vector2 centerToCollider = (Vector2) gameObject.transform.position - parent.GetPosition() + parent.GetCenter(); Vector2 centerToCollider = (Vector2) gameObject.transform.position - parent.GetPosition() + parent.GetCenter();
Vector2 centerToPlayer = (Vector2) player.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) { float angle = Vector2.Angle(( centerToPlayer - centerToCollider ), toOuter);
Debug.Log(centerToCollider.magnitude - 0.89); if ( (angle > 90 && angle < 270) ) {
Debug.Log(centerToPlayer.magnitude); Debug.Log("Player is on the outside! Angle: " + angle);
return; return;
} }
Debug.Log(centerToCollider.magnitude - 0.89);
Debug.Log(centerToPlayer.magnitude);
Debug.Log("Leaving Trigger"); Debug.Log("Leaving Trigger");
if(parent == null) { if(parent == null) {
Debug.Log("This door has no parent Room!"); Debug.Log("This door has no parent Room!");