Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 airbagnr1 · Feb 09, 2018 at 07:57 PM · networkinginstantiateprefabphotonclone

(Clone) from Instantiated Prefabs over Network

Hi guys, now I have read the answers and that to the (clone) after instantiated objects and have followed them and my solution is semi-correct - it works on the PC but not on the phone... So, I'm building a 2d multiplayer game for android using Photon. So when I test the game, I only have 1 android so I make the phone the master and the pc the client. Now when the user presses the button on the PC the object is initiated without the (clone) after its name, whereas this doesn't seem to happen on the phone? Iv been at this for a couple of days and I have no clue why this is. Please help! Thanks in advance for any help given!

Here is my code for reference: public void Player1Button() { player1Activated = true; JoyStickLoading(); thiefCollectorPrefabName = "Thief(Collector)"; RPC_CreatePlayer(thiefCollectorPrefab, thiefCollectorPrefabName, thiefCollectorSpawn); playerControlPannel.SetActive(false); }

So this code here is basically when the user clicks the button, the prefab name is set to Thief(Collector) and then the createplayer method is called which actually initiates the object :

    private void RPC_CreatePlayer(GameObject gameObject, string prefabName, Vector2 spawnVector)
     {
         gameObject = PhotonNetwork.Instantiate(prefabName, spawnVector, Quaternion.identity, 0);
         gameObject.name = prefabName;
     }


Thanks for any help in advance!!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by ChristianSimon · Feb 13, 2018 at 10:27 AM

Hi,

from the code snippets above you are not using the RPC the way it's intended. From the code you are calling the function directly from the Player1Button function. If you want to use RPCs, you have to attach a PhotonView component to the object and use the RPC function of this component. So currently the prefab gets instantiated correctly (which is good so far), but the second part of the function, where you change the name of the object, is just processed on the player who actually pressed the button.

If you want to use PhotonNetwork.Instantiate you don't have to use a RPC call for this. If you want to change the name of the object, you either have to use a RPC call on the object or use InstantiationData with the PhotonNetwork.Instantiate call. It is the last parameter of the second implementation of that function.

If you want to use RPCs, I recommend you taking a look at this official documentation page.

Comment
Add comment · 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

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

144 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 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 Networking Instantiating Problem 0 Answers

What can prevent a prefab network instantiation? 0 Answers

[UNET] How to know the connectionID of a player ? 2 Answers

Photon Instantiated Prefab of OTHER Player Falls Over 1 Answer

script always instantiates monster even when its not supposed to? 1 Answer


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