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 dkh · Dec 30, 2013 at 02:10 PM · transformscenenetwork

Simple Networking Question

I have an empty game object called transformsContainer that should always contain all players. When player 1 hosts a game, I call the SpawnPlayer method:

 public void SpawnPlayer(Transform spawnPoint)
 // spawns a player prefab at a location described by the transform
 {
     GameObject ship = (GameObject)Network.Instantiate(playerPrefab,
         spawnPoint.position, spawnPoint.rotation, 0);
     ship.transform.parent = transformsContainer;
 }

That works fine. Then player 2 joins the game and I call the above function again. On player 2's side, it's own ship that the script freshly created for player 2 is also correctly put in the transformsContainer. But the player 1 ship that is in there from the beginning of the game is not in the game object, it's directly under the root! The same goes vice versa. From player 1's perspective, the ship it created when the game was created is put in the container just fine but when player 2 joins and the SpawnPlayer function is called again for player 2's ship, it doesn't put it in the transformsContainer but under the root again. I should note that I'm not getting any compile- or runtime warnings or errors.

Can anybody explain to me what's going on? :)

Thanks ahead of time.

Comment
Add comment · Show 2
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 nastasache · Dec 30, 2013 at 09:28 PM 0
Share

Probably this because transformsContainer is different on all the connected players and is it filled differently on each player over the timeline. I think better than use Network.Instantiate is to use some RPCs from connected players to the server asking the server to fill transformsContainer then servers sending RPCs to clients with the transformsContainer content. Why don't use simple lists ins$$anonymous$$d of parenting?

avatar image dkh · Dec 31, 2013 at 03:09 PM 0
Share

You're right. $$anonymous$$y mistake was that I didn't consider that only the first line of code would be run via network, there's nothing that makes the second line run on everybody's machine! So that only gets executed on the player's side! That's what I need to use an RPC for. Got it! Thanks!

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.

Follow this Question

Answers Answers and Comments

19 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

Related Questions

connect client - host with tow different scenes 0 Answers

How to load the second online scene in UNET? 0 Answers

why a list of transforms is empty after loading new scene? 2 Answers

Changing the player's starting position depending on the scene transition. 1 Answer

How to move the world/scene not the player - or not? 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