Oculus Avatar with PUN2
Options
Hi there,
I'm new with Photon and I've just learnt the basic with the tutorial.
However, I'm stuck when I want to use the Oculus Avatar tutorial described here:
https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/oculusavatarsdk
In the following part, the
How can I modify this code to work with PUN2? Am I missing something?
Thanks in advance for your help!
I'm new with Photon and I've just learnt the basic with the tutorial.
However, I'm stuck when I want to use the Oculus Avatar tutorial described here:
https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/oculusavatarsdk
In the following part, the
PhotonNetwork.AllocateViewID()
method in PUN2 is taking a PhotonView as a parameter, and return a bool instead of an int.How can I modify this code to work with PUN2? Am I missing something?
public void OnJoinedRoom()
{
int viewId = PhotonNetwork.AllocateViewID();
RaiseEventOptions raiseEventOptions = new RaiseEventOptions
{
CachingOption = EventCaching.AddToRoomCache,
Receivers = ReceiverGroup.All
};
SendOptions sendOptions = new SendOptions
{
Reliability = true
};
PhotonNetwork.RaiseEvent(InstantiateVrAvatarEventCode, viewId, raiseEventOptions, sendOptions);
}
{
int viewId = PhotonNetwork.AllocateViewID();
RaiseEventOptions raiseEventOptions = new RaiseEventOptions
{
CachingOption = EventCaching.AddToRoomCache,
Receivers = ReceiverGroup.All
};
SendOptions sendOptions = new SendOptions
{
Reliability = true
};
PhotonNetwork.RaiseEvent(InstantiateVrAvatarEventCode, viewId, raiseEventOptions, sendOptions);
}
Thanks in advance for your help!
0
Comments
-
Hi @citron,
thank your for the hint. I'm going to update this page soon.
In the meantime the new workflow should look similar to the following steps:- In the OnJoinedRoom callback you would have to instantiate your avatar locally by using
GameObject avatar = Instantiate(...);
- Then you need a reference to its PhotonView component, for example
PhotonView photonView = avatar.GetComponent<PhotonView>();
- You can pass this reference as parameter in
PhotonNetwork.AllocateViewID(photonView);
- Since you already have instantiated the avatar locally, you don't have to send this event to All any longer. So when creating the RaiseEventOptions you can use
Receivers = ReceiverGroup.Others
- When finally raising the event, you want to use
photonView.ViewID
instead of viewId
- Instead of checking if you have to instantiate a Local or Remote Avatar, you can always instantiate the Remote Avatar (it can't be a Local Avatar)
- Assign the ViewId received with the event to the newly instantiated Remote Avatar (looks similar to the code snippet on the documentation page.
0 - In the OnJoinedRoom callback you would have to instantiate your avatar locally by using
-
Thanks a lot!0
-
Hi @citron , have you had any luck with getting this up and running? I am having issues with my app crashing (I'm developing for the Oculus Go) and I'm trying to figure out if my hardware platform is the reason why.0