06-03-2019 03:11 AM
06-20-2019 01:33 PM
VJ76 said:
cloud_canvas said:
re: idiosyncrasies of local vs remote players using Oculus Avatars SDK and PUN 2:
Thx! @cloud_canvas, did you use it yourself? i have experience in developing vr, but i'm new to networking.
06-20-2019 01:40 PM
08-19-2019 09:17 AM
08-22-2019 10:48 AM
private void Start()
{
CreatePlayer();
LoadAvatar();
}
//here's my create player script
public byte InstantiateVrAvatarEventCode = 123;
public void LoadAvatar()
{
GameObject localAvatar = Instantiate(Resources.Load("PUN_LocalAvatar")) as GameObject;
PhotonView photonView = localAvatar.GetComponent<PhotonView>();
//Make avatar child of PUNPlayer
localAvatar.transform.parent = player.transform;
//Center avatar on PUNPlayer
localAvatar.transform.localPosition = Vector3.zero;
localAvatar.transform.localRotation = Quaternion.identity;
if (PhotonNetwork.AllocateViewID(photonView))
{
RaiseEventOptions raiseEventOptions = new RaiseEventOptions
{
CachingOption = EventCaching.AddToRoomCache,
Receivers = ReceiverGroup.Others
};
SendOptions sendOptions = new SendOptions
{
Reliability = true
};
PhotonNetwork.RaiseEvent(InstantiateVrAvatarEventCode, photonView.ViewID, raiseEventOptions, sendOptions);
Debug.Log("Raised Event Set: " + photonView.ViewID + " | " + raiseEventOptions + " | " + sendOptions);
}
else
{
Debug.LogError("Failed to allocate a ViewId.");
Destroy(localAvatar);
}
}
But now it seems like my event data for RemoteAvatar not being sent, here's my CallBack.cs script:public class EventCallbacks : MonoBehaviourPunCallbacks, IOnEventCallback
{
public byte InstantiateVrAvatarEventCode = 123;
public override void OnEnable()
{
PhotonNetwork.AddCallbackTarget(this);
}
public override void OnDisable()
{
PhotonNetwork.RemoveCallbackTarget(this);
}
public void OnEvent(EventData photonEvent)
{
if (photonEvent.Code == InstantiateVrAvatarEventCode)
{
GameObject remoteAvatar = Instantiate(Resources.Load("PUN_RemoteAvatar")) as GameObject;
PhotonView photonView = remoteAvatar.GetComponent<PhotonView>();
photonView.ViewID = (int)photonEvent.CustomData;
Debug.Log("Remote Avatar Instantiated");
}
}
}
Maybe I have it on the wrong GameObject or I'm putting everything in the wrong places (I have no clue). It would be helpful if the photon documentation specified "Create a script for ______ and attach it to ______". I did implement @cloud_canvas's OVRAvatar.cs hack but I'm not even getting the callback error. 08-22-2019 11:12 AM
08-22-2019 11:18 AM
08-22-2019 12:57 PM
08-22-2019 02:03 PM
08-22-2019 02:11 PM
08-22-2019 05:57 PM