Advertisement
11eimilia11

Untitled

Nov 11th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. public class IsPlayerNextToDoor : MonoBehaviour
  2.  {
  3.      public Transform door;
  4.      float distance;
  5.      public float maxAllowedDistance = 3f;
  6.  
  7.      private void Update()
  8.      {
  9.          distance = Vector3.Distance(transform.position, door.position);
  10.  
  11.          if (distance < maxAllowedDistance)
  12.          {
  13.              isPlayerCloseToDoor = true;
  14.              print("Player is close to door");
  15.          }
  16.          else
  17.          {
  18.              isPlayerCloseToDoor = false;
  19.              print("Player is too far from door");
  20.          }
  21.      }
  22.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement