-
Notifications
You must be signed in to change notification settings - Fork 0
/
Door.cs
30 lines (30 loc) · 805 Bytes
/
Door.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using UnityEngine;
using Mirror;
public class Door : NetworkBehaviourNonAlloc, Interactable
{
public Animator animator;
[SyncVar] public bool open;
void Update()
{
animator.SetBool("Open", open);
}
public string GetInteractionText()
{
return (open ? "Close" : "Open") + " door";
}
[Client]
public void OnInteractClient(Player player) {}
[Server]
public void OnInteractServer(Player player)
{
open = !open;
}
void OnValidate()
{
if (animator != null &&
animator.cullingMode != AnimatorCullingMode.AlwaysAnimate)
{
Debug.LogWarning(name + " animator cull mode needs to be set to Always, otherwise the door collider won't move in host or server-only mode.");
}
}
}