Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by ElementalSpark · Oct 15, 2014 at 05:30 PM · networkinginstantiatephotonrpc

Photon Network Instantiate Objects over Network

Hello, need a bit of help:

I am trying to spawn an object in front of the player over the network and allow all players to see that object, but:

 Instantiate(BuildingObjects [CurrentObj].gameObject, obj.position, obj.rotation);

shows the object on my view, but not others.

I have tried to add PhotonNetwork.Instantiate... to it, but throws the error:

No overload method for method instantiate, takes 3 methods.

---- Am I missing something here?? -- I have an RPC set up above the void, but not sure how to call this so that everyone can see the object being spawned over the network.

I have been looking at this code for far too long and need a little bit of help!

Comment
Add comment · Show 1
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 tobiass · Dec 02, 2014 at 09:22 AM 0
Share

You should take a look at the error message, not at your code.

In worst case, try to search the error message "as is" in the internet to find help.

Do the $$anonymous$$arco Polo Tutorial. Code it. Don't just read it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Jeff00001 · Nov 30, 2014 at 03:30 PM

Something like:

[RPC]

void Spawning () {

 if (PhotonNetwork.isMasterClient) {
     SpawnedObject obj = PhotonNetwork.Instantiate ("Enemies", transform.position, transform.rotation,0);

     }

Put your prefab in the root of the resources folder and make sure the prefab's name reflects the string, i.e. Enemies

Comment
Add comment · Show 4 · Share
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 tobiass · Dec 02, 2014 at 09:24 AM 0
Share

Important in that solution is the "is$$anonymous$$asterClient". With the RPC you ask the $$anonymous$$aster Client to Instantiate an enemy. The RPC itself is very likely sent to everyone but only the $$anonymous$$aster Client should react. Else you spawn multiple enemies.

As tip: Use InstantiateSceneObject() on the $$anonymous$$aster Client. This makes sure the enemy stays in the room, even if the current $$anonymous$$aster Client leaves.

avatar image alarm656 tobiass · May 01, 2016 at 07:31 PM 0
Share

please Tobias, may I have more about your tip InstantiateSceneObject()?

avatar image purpl3grape tobiass · May 08, 2016 at 07:22 PM 0
Share

Hi alarm656. This would work as an example:

 if (***PhotonNetwork.is$$anonymous$$asterClient***) {
     int RandNum = Random.Range (0, botSpawnSpots.Length);
     BotSpawnSpot botSpawnSpot = botSpawnSpots [RandNum];
     GameObject enemy = (GameObject)PhotonNetwork.InstantiateSceneObject ("Enemy2", botSpawnSpot.transform.position, Quaternion.identity, 0, null);
     enemy.GetComponent<PhotonView> ().RPC ("SetTeamID", PhotonTargets.AllBuffered, 9);
 }

Tobiass, correct me if I'm going in the wrong direction, but from his needs, The $$anonymous$$aster client Should Control: - $$anonymous$$ovement - Health Points - Destroying Scene object. - Any other functions that rely Enemy Interaction.

avatar image alarm656 purpl3grape · May 09, 2016 at 03:24 PM 0
Share

Hi, purpl3grape. Thank you for your answer to me. From your scrip I understood that I need additional "BotSpawnSpot" script right? Actually I would like to know projectile shooting with visible bullets by using RPC method. So please if you have a time could you open this link and correct me please. I can't sync bullet across network. http://forum.photonengine.com/discussion/7624/shooting-like-in-demo-project-angry-bots#latest

This links directs you to my question in photon engine forum. Any help will be appreciated. Thanks in advance. Hope you'll make my day today:)

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.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Proper way to instantiate projectile in PUN 1 Answer

Sync An Object not Controlled by Players 1 Answer

RPC failed to send 1 Answer

Photon (PUN) Type Serialization Error on RPC 2 Answers

Photon/Network - Killing A Client Enemy Unit 3 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