The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Instantiate the game object for the local player only

francvol
2021-03-23 20:45:23

Greetings to all, sorry for my writing, but I am Italian and I have translated the text automatically.
I have a problem that I have not been able to solve for 4 days, I am here to ask for a little help.
I'm trying to get checkpoints to work, my problem is that I add checkpoints via PhotonNetwork.Instantiate, so far everything works fine, but when I try to show or hide the checkpoints, the command has global effect.
I have made many attempts with photonView.IsMine, but have not been successful.
The goal is to show each player only their own checkpoints and not those of others.
I thank anyone who wants to help me.

Comments

JohnTube
2021-03-23 21:08:09

Hi @francvol,

Thank you for choosing Photon!

It's OK, most of us here are not native English speakers.

About your question: first of all why do you need to network instantiate if you need it only on the local client? use Unity's Instantiate then.

Otherwise, you may want to instantiate objects as hidden and unhide them locally then? or just do this via a script next to PhotonView and hide or show in Awake or Start?

francvol
2021-03-23 21:17:00

@JohnTube wrote: »

Hi @francvol,

Thank you for choosing Photon!

It's OK, most of us here are not native English speakers.

About your question: first of all why do you need to network instantiate if you need it only on the local client? use Unity's Instantiate then.

Otherwise, you may want to instantiate objects as hidden and unhide them locally then? or just do this via a script next to PhotonView and hide or show in Awake or Start?

The pleasure is mine, I thank you and the staff for this fantastic tool, sure of an excellent collaboration.

A to each checkpoint I assign a status, and this must necessarily be different between the players, for this reason I generate the same number of checks for each player

francvol
2021-03-24 21:18:17

I solved my problem.
I was practically trying to instantiate prefabs as inactive, but this is not allowed by Unity which automatically brings them back to active status.
While I was trying to enable only my items, the system enabled all checkpoints including those of other players.
It was enough to disable the other checkpoints to make my logic work correctly.
I hope this information will be useful.

Back to top