Hi everyone, hope u all have a great summer!
I have a problem with Photon Syncing.
I have this gameobject which is a door that i need to do so everyone can open and close but only the host can open the door and the connected players can see it half open and like going back and forward in the swing, what causes this?
I have a photon transform and photon view on which u can see in the images
I have also attached a image with the code, but u can also see the code for the door below
(Players interact with the door with a interact script which is on the players camera)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class Door : MonoBehaviour {
[SerializeField] public bool DoorOpen = false;
[SerializeField] public int DefaultRotation = 0;
[SerializeField] public bool Locked = false;
public enum State
{
left,right
}
[SerializeField]
public State rotate;
[SerializeField]
private int RotateVal;
private void Start()
{
if (rotate == State.left)
RotateVal = -90;
else
RotateVal = 90;
}
void Update()
{
if (DoorOpen)
{
Quaternion newRotation = Quaternion.AngleAxis(RotateVal, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, 0.1f);
}
else
{
Quaternion newRotation = Quaternion.AngleAxis(0, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, 0.1f);
}
}
public void OpenDoor()
{
Debug.Log("Opening door");
if (Locked == false)
{
if (DoorOpen)
{
DoorOpen = false;
Debug.Log("1");
}
else
{
DoorOpen = true;
Debug.Log("2");
}
}
}
}