44 lines
938 B
C#
44 lines
938 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using Mirror;
|
||
|
|
||
|
public class DefaultDoor : NetworkBehaviour, IInteractable
|
||
|
{
|
||
|
[SyncVar]
|
||
|
public bool state = false;
|
||
|
|
||
|
public float maxAngle, speed;
|
||
|
|
||
|
private float yAngle;
|
||
|
|
||
|
public Transform door;
|
||
|
|
||
|
// public List<Transform> doorList;
|
||
|
|
||
|
void Update()
|
||
|
{
|
||
|
yAngle = Mathf.Lerp(yAngle, (state ? 1f : 0f) * maxAngle, Time.deltaTime * speed);
|
||
|
|
||
|
door.localRotation = Quaternion.Euler(0, yAngle, 0);
|
||
|
|
||
|
// for (int i = 0; i < doorList.Count; i++)
|
||
|
// {
|
||
|
// float side = i % 2 > 0 ? 1 : -1;
|
||
|
|
||
|
// doorList[i].localRotation = Quaternion.Euler(0, yAngle * side, 0);
|
||
|
// }
|
||
|
}
|
||
|
|
||
|
public void Interact()
|
||
|
{
|
||
|
CmdInteract();
|
||
|
}
|
||
|
|
||
|
[Command(requiresAuthority = false)]
|
||
|
private void CmdInteract(NetworkConnectionToClient sender = null)
|
||
|
{
|
||
|
state = !state;
|
||
|
}
|
||
|
}
|