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 Jazzer008 · May 25, 2013 at 07:19 PM · instantiateprefabnetworkproceduralnon

Network.Instantiate a non-prefab?

I'm procedurally generating some spaceships which the players control. How can I send these objects over the network as Network.Instantiate keeps saying I have to spawn a prefab assigned within the editor.

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 Tomer-Barkan · May 25, 2013 at 07:31 PM

The way Network.Instantiate works, is that it sends the identifier of the prefab to all the clients, and not the prefab itself. So this means that the prefab must exist in all the clients, and not just on the server.

Hence, you are only able to instantiate prefabs with Network.Instantiate, you cannot instantiate procedurally generated objects.

Read about it in the documentation: http://docs.unity3d.com/Documentation/Components/net-NetworkInstantiate.html

And read here about alternatives to instantiate a non-prefab: http://answers.unity3d.com/questions/163493/networkinstantiate-a-non-prefab.html

And here: http://docs.unity3d.com/Documentation/Components/net-RPCDetails.html

Comment
Add comment · Show 3 · 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 Jazzer008 · May 25, 2013 at 07:51 PM 0
Share

Yeah, I saw that alternative, didn't help me much.

The RPC call though. If I'm right in understanding this, I could call the same function on every machine, using some kind of seed to generate the same ship on each machine?

Atm I just use random.range and all that basic stuff, how would I link it up to a seed?

avatar image Tomer-Barkan · May 25, 2013 at 08:30 PM 0
Share

Yes, exactly. Calculate the random values on the server, and then serialize them to a string to send to the others via the RPC call.

Another thing you might try (haven't tried myself) is to generate a random seed, and then send it to all clients. Then set them all to the same seed with "Random.seed", and they should generate the same values in the next random calls.

avatar image Jazzer008 · May 25, 2013 at 08:39 PM 0
Share

Yeap, I guess that's the best way. Thanks for your help. :P

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

14 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

Related Questions

Problem with Camera instantiating 1 Answer

prefabs automaticly saved as inavtive. 1 Answer

inserting random gun into player/enemies hands 3 Answers

Unity not Instantiating Prefabs Properly 0 Answers

Brain freeze: declaring a prefab inside the same prefab 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