• 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
Question by iancant · Jun 13, 2012 at 02:47 PM · networkinginstantiateserverclient

Network.Instantiate issues - GameObject ownership and network views?

We are some weird behvaiour with Network.Instantiate we are calling it to spawn cars in a racing game for a game jam. The players are assigned a unique ID from the server to indicate their starting position. Network connection all works fine and RPC calls go through perfectly correctly.

 // Start the race
 public void BeginRace() {
     if(!networkManager.IsServer())
     {
         Vector3 carPosition = new Vector3();;
         Quaternion carRotation;
         
         switch(networkPlayerID)
         {
         case 1:
             carPosition = new Vector3(841.8432f,102.1979f,808.0422f);
             break;
         case 2:
             carPosition = new Vector3(841.6416f, 102.1979f, 816.8533f);
             break;
         case 3:
             carPosition = new Vector3(828.7191f, 102.1979f, 807.7421f);
             break;
         case 4:
             carPosition = new Vector3(828.7191f, 102.1979f, 816.1051f);
             break;
         }
         
         // Spawn the car
         GameObject car = (GameObject)Network.Instantiate(car1Prefab, carPosition, new Quaternion(0f, Mathf.PI * 0.5f, 0f, 0f), 0);
         
         // Pair the camera to the car
         GameObject camera = GameObject.FindGameObjectWithTag("CarCamera");
         CarCamera cameraScript = camera.GetComponentInChildren<CarCamera>();
         cameraScript.target = car.transform;
     }
     
     // Start HUD Countdown
     hud.StartCountdown();
 }

We find that if 1 player connects. It spawns on the client and on the server and the camera is paired to the car correctly. However if multiple clients connect we have issues. The correct number of cars spawn in the correct position on each client. The camera is paired to the correct car. However the server (which spawns no cars) fails to show any cars. Also the user controls all 3 cars.

Anyone got any ideas on what's going wrong?

Comment

People who like this

0 Show 1
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 iancant · Jun 13, 2012 at 01:11 PM 0
Share

Ok We've managed to fix the user controlling all 3 cars. Only problem we are having now is that Network.Instantiate calls don't seem to be sending the instantiate command to all clients?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Level Instantiation running on Server and client 0 Answers

Unity networking tutorial? 6 Answers

Instantiated object from client player not moving when spawned. How can I fix this? 0 Answers

Networking slow game objects 0 Answers

Unity UDP freezes if disconnected from server 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