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 /
This question was closed Dec 10, 2012 at 02:59 PM by Eeppi for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Eeppi · Dec 08, 2012 at 12:20 PM · multiplayerfirst person

Multiplayer first person camera

EDIT 10.12.2012:

I need still help with this (Copy - paste from comment):

Something is probably wrong with my logic, but I can't find it myself. (It works, but it's like inverted.. Player 1 can move player 2 and player 2 can move player 1.) My code is now like this:

 @RPC
 
 function Startgame(){
 
 Application.LoadLevel("TestMap");
 
 }
 
 function OnLevelWasLoaded(){
 
 if (networkView.isMine){
 
    AddPlayer();
 }
 
 if (!networkView.isMine){
 
    AddPlayer(); 
 
    Destroy(camera1);    
 }
 
 }
 
 function AddPlayer(){
 
 Network.Instantiate(playerPrefab, spawnObject.position,Quaternion.identity, 0);
 
 }
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

  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Dec 08, 2012 at 12:37 PM

You need to change the scripts on the player object. The playerobject has to check to whom it belongs and disable / remove components which shouldn't be there on the other clients.

Basically your controls have to be surrounded with:

 if(networkView.isMine)
 {
     // control the player
 }

And in Start of a script on the player object you should remove components like camera (which usually has the audiolistener as well)

So just make a public variable on the player script where you can reference it's own camera object (which should be a child of your player object):

 var cam : GameObject;
 
 function Start()
 {
     if (!networkView.isMine)  // if this is not my player, remove the camera
         Destroy(cam);
 }
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 Eeppi · Dec 08, 2012 at 02:34 PM 0
Share

I got it working, but it's still inverted like with my old code. So Player 1 can move player 2 and player 2 can move player 1. What could be wrong?

avatar image Bunny83 · Dec 08, 2012 at 11:29 PM 0
Share

The owner of an object (the owner is the only one that can actually update the state of the object across the network) is always the player that created the NetworkViewID which will be created when a NetworkView is instantiated. So the player calling Network.Instantiate will own the object.

avatar image Eeppi · Dec 09, 2012 at 08:54 AM 0
Share

Something is probably wrong with my logic, but I can't find it myself. (It works, but it's like inverted.. Player 1 can move player 2 and player 2 can move player 1.) $$anonymous$$y code is now like this:

@RPC

function Startgame(){

Application.LoadLevel("Test$$anonymous$$ap");

}

function OnLevelWasLoaded(){

if (networkView.is$$anonymous$$ine){

    AddPlayer();

}

if (!networkView.is$$anonymous$$ine){

    AddPlayer(); 

    Destroy(camera1);    

}

}

function AddPlayer(){

Network.Instantiate(playerPrefab, spawnObject.position,Quaternion.identity, 0);

}

Follow this Question

Answers Answers and Comments

10 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

Related Questions

Multiplayer First Person controls other character? 0 Answers

Unity networking tutorial? 6 Answers

Sometimes when gone into game mode with the first person preset package, the controls won't work? 0 Answers

camera spectator mode multiplayer 1 Answer

Multiplayer - Standing Still Makes Player Disappear 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