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 Vel_1828 · Jan 20, 2015 at 12:44 AM · networkinginstantiatemultiplayernetworkparent

Network.Instantiate is CHAOS.

TL;DR At the Bottom.

I honestly did not have any other idea of how to name this thread.

Network.Instantiating objects is completely random.

From the start:

I'm making a first networking game project to teach myself how to do it. A simple, 3 player shooter.

Of course I have watched and read tutorials for days now and implemented everything accordingly.

When a Player enters the game, he is being spawned. Right after that, his mesh is separately Network.Instantiated and childed to him (due to an option to change your character skin via Playerprefs). In the game itself, the Players can change weapons, from 1 to 3 (knife, pistol, shotgun, basics). These weapons are made through Net Instantiate too - at weapon change the current weapon is Net.Destroyed and a selected one is Net.Instantiated.

As long as in the game is only one player - all's fine. Now the problem is - the outcome of NetInstantiating is almost always random when a second player enters.

The parenting of instantiated objects sometimes works, sometimes not, their scaling is most of the times screwed up, the Objects often appear at V3(0,0,0) or at their desired spawn point, they are getting Instantiated in multiple copies scattered around the scene... it's just a fire-engulfed Jason Polloc paining.

SO FAR I have tried several different configurations of NetworkView.isMine, changing RPC functions, messing with NetView.vieid's and so on and so on. Heck, I even added NetworkViews on EVERYTHING in an act of a Weltschmerz agony. Not mentioning animations not playing over network but that's a different matter.

The Internets are getting even worse when it comes to googling my answers, because everything just doesn't work as intended or there's no intel on these issues.

TL;DR / CONCLUSION

Can anyone create a simple (JavaScript prefered though not required) example of a script, which on demand of only his owning Player spawns and parents a single Object, (like a script, that instantiates a child weapon on player parent), so it can be used as a template for future creations? Thank you, kind adventurer, in advance. You're saving lifes right now.

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
1
Best Answer

Answer by jpthek9 · Jan 20, 2015 at 12:58 AM

I'll be honest, your question truly was tl;dr so thanks for that last synopsis. Check out this guy: https://www.youtube.com/watch?v=AIgwZK151-A on how he makes a multiplayer shooter. It's really clear and helpful. He uses Photon Unity Networking but the concepts and code are mostly the same or similar. I.e. Instead of Network.Instantiate it's PhotonNetwork.Instantiate.

A simple way to instantiate something and child it is to use an RPC to instantiate rather than Network.Instantiate.

 public GameObject Gun; //The gun to instantiate.
 public GameObject Player; //Represents the player for the gun to be attached to
 [RPC]LeInstantiate()
 {
 GameObject LeGun = Instantiate(Gun, Vector3.zero, Quaternion.identity) as GameObject;
 LeGun.transform.parent = Player;
 LeGun.AddComponent<NetworkView>();
 }
Comment
Add comment · Show 1 · 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 Vel_1828 · Jan 20, 2015 at 11:57 PM 0
Share

Guess I'll give it a try. Thanks. ;)

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

26 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

Related Questions

Unity networking tutorial? 6 Answers

How can I spawn a GameObject on all players in my multiplayer game? 0 Answers

Players Not Showing 0 Answers

Network.Destroy doesn't remove objects on other systems? 2 Answers

Unet NetworkServer.Spawn() not working 5 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