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
0
Question by r4yan · Oct 05, 2017 at 11:49 AM · multiplayercameras

Multiple cameras in multiplayer

I'm having the same kind of problem as the one mentioned here: http://answers.unity3d.com/questions/1405957/cameras-in-multiplayer-game-unity.html

So basically, I'm trying to make a multiplayer game, and I've set-up the networking using unity. In the network controller, I've set the player prefab to be the FPS Controller with a network identity. However, when I try to have two instances of the game running (the host and the client), when the client connects to the host, the host's camera is switched to the same camera as the client. How do I set it up so that the host and client have different views or cameras? Any help is much appreciated.

Thanks!

Comment
Add comment · 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 r4yan · Oct 05, 2017 at 11:51 AM 0
Share

EDIT - Forgot to mention that I'm fairly new to Unity and if this is a noob question, sorry in advance.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ristophonics · Jan 19, 2018 at 07:22 AM

Okay, I had the same problem and followed the posts until I could create the following answer. On the playerprefab being instantiated I placed the following script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Networking;
 
 public class CameraControllerNet : NetworkBehaviour {
 
     private GameObject cameraRigToGrab;
     public GameObject _cameraPositionMarker; //an empty on my player where the cam should be
 
     public override void OnStartLocalPlayer()
     {
         cameraRigToGrab = GameObject.Find("OVRCameraRigForCG"); //actually camera's parent
         if (isLocalPlayer)
         {
             cameraRigToGrab.transform.position = _cameraPositionMarker.transform.position;
             cameraRigToGrab.transform.rotation = _cameraPositionMarker.transform.rotation;
             cameraRigToGrab.transform.SetParent(_cameraPositionMarker.transform);
 
             return;
         }
     }
 }


First: You DO NOT unintentionally want more then one Camera in the scene, so simply remove any from prefabs that might generate them automatically and place your ONE MainCamera in the scene alone. My MainCamera in the script below is "OVRCameraRigCG." Just replace that name with your MainCamera's parent name. If your MainCamera does not have a parent create an EmptyGameobject as it parent, name it MainCameraRig and reference that name exactly.

The script essentially says: 1) Find the camera in the scene that I want. 2) Move that camera to the position and rotation of my CameraMarker // this is an empty Gameobject on the playerprefab where you want you camera to be 3) Make the CameraMarker my camera's new parent

Hope that helps. It tests out working so far.

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

117 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 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 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 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 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 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 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

SplitScreen shooter with Viewmodels and PlayerModels without so many layers? 1 Answer

Unity networking tutorial? 6 Answers

How to Modify Multiplayer Script for iPhone 0 Answers

How do i turn on and off a network camera? 0 Answers

Webplayer Facebook game- is a PHP script and a Unity script sufficient? 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