draw debug door vector
This commit is contained in:
parent
a0a48cb256
commit
3f55812533
1 changed files with 6 additions and 1 deletions
|
@ -69,6 +69,10 @@ public class Door : MonoBehaviour {
|
||||||
return locked;
|
return locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Update() {
|
||||||
|
Debug.DrawLine(gameObject.transform.position, gameObject.transform.position + new Vector3(toOuter.x, toOuter.y, 0));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if a player moved inside of a room and notify the room.
|
/// Check if a player moved inside of a room and notify the room.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -79,7 +83,8 @@ 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();
|
||||||
float angle = Vector2.Angle(( centerToPlayer - centerToCollider ), toOuter);
|
float angle = Vector2.Angle(toOuter, ( centerToPlayer - centerToCollider ));
|
||||||
|
|
||||||
if ( (angle > 90 && angle < 270) ) {
|
if ( (angle > 90 && angle < 270) ) {
|
||||||
Debug.Log("Player is on the outside! Angle: " + angle);
|
Debug.Log("Player is on the outside! Angle: " + angle);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue