• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by NanoEngine · Mar 23, 2017 at 05:08 PM · networkinginstantiatephotoninstantiate prefab

PhotonNetwork.Instantiate is not "buffered"

Hello, I'm currently creating simple multiplayer first person shooter using PhotonNetwork engine, but I got crushed into the problem.

The problem I have is this:

I spawn Player1 using Manager by (PhotonNetwork.Instantiate)

I spawn Player2 using Manager by (PhotonNetwork.Instantiate)

but the problem is player1 can see player2, but player2 cannot see player1. I figured it out that it's not "buffered" Is there a way to solve this problem?

Comment
Add comment · Show 10
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ChristianSimon · Mar 28, 2017 at 08:21 AM 0
Share

Hi,

PhotonNetwork.Instatiate(...) is buffered, so there shouldn't be a problem with that. Do you use the group parameter of the function (the last one) with any value else than 0 in one of these cases? In this case you need to set sending and receiving enabled for all clients.

avatar image NanoEngine · Mar 29, 2017 at 07:02 PM 0
Share

$$anonymous$$y group parameter is "0" Here is my piece of code where I instantiate the object:

 player = (GameObject)PhotonNetwork.Instantiate("myPlayer", Vector3.zero, Quaternion.identity, 0);
avatar image NanoEngine · Mar 30, 2017 at 07:09 PM 0
Share

I thought I did solved the problem, but I didn't. I'm still having this problem. Please someone help me. The thing is whenever I try the photonnetwork.Instantiate in my "test project", and it worked. I think there is something with my script...

         player = (GameObject)PhotonNetwork.Instantiate("myPlayerClassInit", new Vector3(0, 10, 0), Quaternion.identity, 0);
         player.GetComponent<LobbyPlayerSetup>().enabled = true;

This is litterly what I have in void Start() method... Please help me

avatar image ChristianSimon · Apr 03, 2017 at 08:41 AM 0
Share

You can try moving the Instantiation call from the Start() function to a OnJoinedRoom() callback. This makes sure that the client has definitely joined the room.

Can you tell us what happens in LobbyPlayerSetup script / component? I am also a bit confused about this name, because there are differences about the lobby and the room.

avatar image NanoEngine · Apr 04, 2017 at 03:20 PM 0
Share

Ok, in LobbyPlayerSetup, it's where I change the name of an object that I instantiated. I used simple GetComponent().RPC("ChangeName", PhotonTargets.AllBuffered, username); and there is no problem with it.

I'll explain you the scene. So basically, I''m trying to make a class selection scene. When ever the player gets into the room, I instantiate an object to the class selection scene, and in that object, there are some variables such as "current Class" or which $$anonymous$$m i'm belonging. And I made sure that instantiation call is called AFTER when player joined room. I checked using simple "ConnectionStateDetailed", and I even gave a little bit of delay using StartCorutine, and tried "OnJoinedRoom".

avatar image ChristianSimon · Apr 06, 2017 at 08:29 AM 0
Share

Rena$$anonymous$$g those objects shouldn't be a problem as you have also noticed. Do you instantiate the class selection object only locally or is this an networked object as well?

I have tried to create a similar test case which works fine, so I guess I'm missing something you have done in / added to your project. Can you maybe share me a repro case so I can investigate on this behaviour in more detail?

avatar image NanoEngine · Apr 07, 2017 at 02:35 PM 0
Share

If I understand your question right, I use network$$anonymous$$anager gameobject(which is there at the very start of the game). I tried to do the same setup on my other project. and apparently, it worked perfectly, I don't know what's the problem. I head back to the original project, and it still didn't work.

avatar image ChristianSimon · Apr 10, 2017 at 01:47 PM 0
Share

Did you already have the second client (the one who joins the existing game) run in Unity editor? What I basically want to know is if the second player instantiates his prefab and the other player's prefab as well and if you have two characters in the hierarchy afterwards.

Another question: Have you already tried what happens if you run and connect a third client? Do we have the same behaviour? Such as Player 3 doesn't see any other client, but Player 2 sees the third client as well as Player 1 does?

avatar image NanoEngine · Apr 10, 2017 at 04:32 PM 0
Share

Player2 only sees player2 in hierarchy, and player1 sees player1 and player2 in hierarchy.

For the second question, I just tested it out with player 3 and this happenend:

Player1 joins in Player2 joins in Player3 joins in

Player1 can see all Player1 and Player2 and Player3 Player2 can see both Player2 and Player3 Player3 can only see Player3

avatar image ChristianSimon · Apr 20, 2017 at 08:30 AM 0
Share

Sorry for the delayed response.

Do you load another scene after (or before) the player has instantiated his prefab? This can cause the described behaviour you currently have problems with.

You can also check what happens on client 2 and 3 by adding another script to the prefab. In this script you can use Awake() and OnDestroy() functions and add some debug logging to them. Every client should only call the Awake() function when the prefab gets instantiated. If not every client calls Awake() or one of them also calls OnDestroy(), you maybe have a problem with scene loading or something else we need to find out afterwards.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

103 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Photon Network Instantiate Objects over Network 1 Answer

[Photon] Looking for example code for late joining clients syncing instantiated game objects that don't exist in the base scene 0 Answers

Using RPC to Instantiate 1 Answer

How do I instantiate and set the parent of a Gameobject using Photon? 0 Answers

Photon Unity Networking - Player Camera Instantiate 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges