Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class IsPlayerNextToDoor : MonoBehaviour
- {
- public Transform door;
- float distance;
- public float maxAllowedDistance = 3f;
- private void Update()
- {
- distance = Vector3.Distance(transform.position, door.position);
- if (distance < maxAllowedDistance)
- {
- isPlayerCloseToDoor = true;
- print("Player is close to door");
- }
- else
- {
- isPlayerCloseToDoor = false;
- print("Player is too far from door");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement