IPunInstantiateMagicCallback issue in UCC PUN scenes

nathanj

Active member
Hi Justin

I'm trying to get Dissonance Audio working with UCC for networked audio.

I've run into a problem, for some reason the callback
Code:
 void IPunInstantiateMagicCallback.OnPhotonInstantiate(PhotonMessageInfo info)
is never called within a UCC PUN scene.

It works in the Dissonance scene but for some reason it's not working in the UCC scene.

Any idea why this would be?


Thanks,
Nathan
 
Last edited:
So I'm pretty sure it's how how the two programs instantiate the player.

Dissonance uses this to instantiate the player:
Code:
PhotonNetwork.Instantiate(ObjectToSpawn.name, pos, Quaternion.identity, 0);

While Opsive uses
Code:
var player = GameObject.Instantiate(GetCharacterPrefab(newPlayer), spawnPosition, spawnRotation);
            var photonView = player.GetComponent<PhotonView>();
            photonView.ViewID = PhotonNetwork.AllocateViewID(newPlayer.ActorNumber);

and then uses this event
Code:
PhotonNetwork.RaiseEvent(PhotonEventIDs.PlayerInstantiation, data, m_RaiseEventOptions, m_ReliableSendOption);

So, does anyone here know if I can somehow use the event to trigger a callback like
Code:
void IPunInstantiateMagicCallback.OnPhotonInstantiate(PhotonMessageInfo info)
meantioned above?

Thanks in advance.
Nathan
 
Hmm, I'm not sure as I haven't used that callback before. I would try posting this on the Photon forums to see if they can help. The add-on uses this method for spawning players:

 
Thanks Justin

Just a heads up, I'm a bit lost with this so aplogies if this is confusing or just simply wrong.

Are you aware of a single event that is called when a new player is entered to the scene? In the SpawnManagerBase there seems to be different calls for local or remote player's.

At the moment I have
Code:
public void OnEvent(EventData photonEvent)
with
Code:
if (photonEvent.Code == PhotonEventIDs.PlayerInstantiation)

and
Code:
private void OnPlayerEnteredRoom(Player player, GameObject character)
to register when a new player is added.

It kind of works but not the same way that IPunInstantiateMagicCallback.OnPhotonInstantiate does. I believe I need the OnPlayerEntered to register when a remote player enters and the OnEvent to register when the local player enters. Is there some single call I can tap into whenever a player is added to the scene?

Thank you,
Nathan
 
Last edited:
The OnPlayerEnteredRoom event is sent from the master client after a new character has been added within the add-on. This event originates from the PUN MonoBehaviourPunCallbacks.OnPlayerEnteredRoom. It sounds like you could override the OnPlayerEnteredRoom method to catch all use cases?
 
Top