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 theOtherHolmes · Oct 26, 2015 at 09:49 AM · instantiatephoton

Photon.Instantiate causes second-created player to swap places with first

Obviously working with PUN here. I'm creating a game based on the Marco Polo tutorial. I'm running one instance of the game on Computer 1 (my main machine), and I'm running another (build) instance on Computer 2 (the laptop sitting next to my main machine). (I'm running the other instance on a separate machine just to make sure that two instances on the same machine was not causing the problem I'm about to describe.)

I start one instance on Computer 1, go through the lobby, create the room, and join the room. My player prefab spawns at a random spot within a certain zone.

I start the second instance on Computer 2, join that game, and this new prefab should also spawn at a random place within the same zone, but instead, it immediately switches places with the spawned player on Computer. And the player on Computer 1 goes somewhere else (I assume where the Computer 2 prefab would have spawned, if it was working right).

The spawning code is pretty standard:

 Vector3 spawnPosition = new Vector3(Random.Range(-10.0F, 10.0F), 0f, Random.Range(-10.0F, 10.0F));
 PhotonNetwork.Instantiate(this.playerPrefab.name, spawnPosition, Quaternion.identity, 0);

Any thoughts why this might happen? Thanks.

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
2

Answer by Michael_-01-_ · Oct 26, 2015 at 12:34 PM

I am also working with PUN and one thing that you have to look out for is your player controlled scripts and camera's in the scene. I don't know if you have done this but make sure that your camera of your player prefab is disabled and then enable it with a script when you spawn the player, do the same for player controlled scripts, otherwise players would be able to control each other x_x Hope this helps :D

Comment
Add comment · Show 2 · 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 theOtherHolmes · Oct 26, 2015 at 02:01 PM 0
Share

Good point. Now that I look closely at the behavior of the prefabs when I try to control them, I think you're right -- I need to make sure my camera scripts are really doing what they say they're doing. That might be the problem. Thanks.

avatar image Denis-Yurkov · Nov 13, 2021 at 03:11 PM 0
Share

I tried to fix this bug for a week. Thank you so mush!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Control spawned Photon Player with spawned new UI 0 Answers

Photon instantiate (Assign Instantiated . get component 1 Answer

How to add a component to a prefab 1 Answer

photon Spawn 4 players in different positions 0 Answers

Using RPC to Instantiate 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