Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by Vincent22 · May 31, 2011 at 07:23 AM · instantiateprefabmultiplayernetworkonline

Player Instantiate in online game

Hi everybody. I'm developing a simple multiplayer online game with Unity3d. I have a problem with player instantiate. For each player I network instantiate an empty game object prefab and I instantiate the character prefab and make it child of empty game object prefab (I use this method because I have some problem with character pivot and orientation). The problem is that players that are playing can see only the other empty object and not the other child object (the remote characters). How can I solve my problem? This is my code:

 var respawn_x=Random.Range(-3134.925,-3473.049);
 var respawn_z=Random.Range(645.9182,941.0953);
 var respawn_y = 206.66;
 var ObjectParent = Network.Instantiate(GameObjectVuoto, transform.position, transform.rotation,0);
 charController = ObjectParent.GetComponent(CharacterController);
 charController.radius = 15.04244;
 charController.height = 38.8195;
 pl = Network.Instantiate(characterPrefab, transform.position, transform.rotation,0);
 pl.transform.parent = ObjectParent.transform;
 ObjectParent.transform.position = Vector3(respawn_x,respawn_y,respawn_z);
 pl.transform.Rotate(Vector3(0,355.5273,0));


I've tried making a network.instantiate also for the character prefab (attaching a network view) but it doesn't work.

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
Wiki

Answer by Matt- · May 02, 2012 at 08:53 PM

Aside from the Network.Instantiate calls, everything else is only being done LOCALLY. So the GameObjectVuoto is being created for everyone, but the charController.radius and charController.height are not being set.

Similarly p1 gets created for every instance on the network but will only have its transform.parent and position set on the local side.

 // this creates an instance of characterPrefab 
 // on EVERY connected computer
 pl = Network.Instantiate(characterPrefab,transform.position,transform.rotation,0);
     
 // this sets the parent of my LOCAL INSTANCE ONLY
 // no changes are made on any other connected computer
 pl.transform.parent = ObjectParent.transform;

To get this to work you'll have to move all of those updates into an RPC, and then call those RPCs to get the changes to be effected on every connected instance instead of just locally.

http://unity3d.com/support/documentation/Components/net-RPCDetails

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiplayer Projectile Instantiation 1 Answer

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

How to close multiple GUI Buttons and open other gui buttons 1 Answer

Network.Instantiate instantiazing 2 prefabs 1 Answer

Network.Destroy doesn't remove objects on other systems? 2 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