Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Mirror;
  5.  
  6. public class Door : NetworkBehaviour
  7. {
  8.  
  9.     public DoorPermissions permissions;
  10.     public Animator doorAnimator;
  11.  
  12.     private bool open = false;
  13.     private bool debounce = false;
  14.  
  15.     public void RequestDoorOpen(PDATool PDA) {
  16.         if (isServer) {
  17.             bool allowOpen = permissions.validateOpen(PDA.access);
  18.  
  19.            
  20.             if (allowOpen && !debounce) {
  21.                 open = !open;
  22.                 Debug.Log("Status: " + open);
  23.                 doorAnimator.SetBool("IsOpen", open);
  24.                 debounce = true;
  25.                 StartCoroutine("killDebounce");
  26.             }
  27.         }
  28.     }
  29.  
  30.     IEnumerator killDebounce() {
  31.         yield return new WaitForSeconds(1f);
  32.         debounce = false;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement