• 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
Question by william9518 · Aug 09, 2013 at 02:10 AM · networkingplayernetworkviewid

NetworkView is always mine, so can control all players

Hello. I am relatively new on these forums so please excuse if my question is not detailed enough. I have recently made my game multiplayer, with menus and networking all set up. At the moment you can control all the players, but I know why. My NetworkView.isMine always returns true. I will give a little code segment here:

 @RPC
 function InstantiateNetworkPlayer(){
     var temp : GameObject = new GameObject();
     temp.transform.position = new Vector3(0, 0, 0);
     temp.transform.eulerAngles = new Vector3(0, 0, 0);
     myPlayer = Network.Instantiate(PlayerPrefab, temp.transform.position, temp.transform.rotation, 0);
     if(myPlayer.networkView.isMine){
         myPlayer.GetComponent(FPSInputController).enabled = true;
         myPlayer.GetComponent(MouseLook).enabled = true;
         myPlayer.transform.Find("Spine/Main Camera").GetComponent(Camera).enabled = true;
     } else {
         myPlayer.GetComponent(FPSInputController).enabled = false;
         myPlayer.GetComponent(MouseLook).enabled = false;
         myPlayer.transform.Find("Spine/Main Camera").GetComponent(Camera).enabled = false;
     }
 }

Now as you can see, t$$anonymous$$s is my player instantiating code, and is called in a OnConnectedToServer() function. You can see that I stated that if my player is not mine, I disable the FPSInputController, MouseLook, and the Camera. When I play the game, however, I join the game with another window open, I have the ability to move both my characters. And so vice-versa as the host. Any help would be appreciated, in either Javascript or C#.

Thanks in advance, william9518

Comment

People who like this

0 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 Jamora · Aug 09, 2013 at 08:49 AM 0
Share

Why is your function an RPC? It only needs to be called on the connecting player. My guess is that you have a networkView.RPC with sendmode all in your OnPlayerConnected so everyone instantiates their own player.

avatar image william9518 · Aug 09, 2013 at 01:07 PM 0
Share

It is an RPC because I need all my players to see the instantiated prefab.

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by whydoidoit · Aug 09, 2013 at 01:34 PM

See my question/answer here: http://answers.unity3d.com/questions/252128/networkviewismine-confusion.html

It appears that isMine returns true until the first Update call...

Comment

People who like this

0 Show 0 · 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

Answer by Yokil · Aug 09, 2013 at 01:34 PM

Try read t$$anonymous$$s:

http://www.playblack.net/zee-code/unity-3d-authoritative-server-networking-pt2

Comment

People who like this

0 Show 0 · 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.

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

17 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

Related Questions

Help with player variables (prefab/network) 1 Answer

Make an enemy follow a player through network 4 Answers

Send information from one player to another. Unity Multiplayer 2 Answers

Changing to online sceen in multiplayer 0 Answers

Multiplayer lagging in player but not in editor. 0 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