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 /
avatar image
0
Question by Tomate · Nov 26, 2011 at 10:34 PM · cameranetworkingmultiplayer

Networking Camera

Hey there! I've finally created a prototype of a MP Game - creating Server, joining and moving is no problem. But its actually not possible for me, to give every Player his own Camera. Just the Host gets a Camera, every else Player is only able to see the view through MainCam.

Script in NetworkSpawn

 var Clone: Transform;
   Clone = Network.Instantiate(playerPrefab, transform.position, transform.rotation,0);
   Camera.main.SendMessage("SetTarget", Clone.transform);

and Camera Script:

 var Target : Transform;
 
 var distanceFromPlayer: int = 20;
 
 
 
 function LateUpdate () {
 
  if (Target)
 
  {
 
   transform.position.x = Target.position.x;
 
   transform.position.z = Target.position.z - distanceFromPlayer;
 
   transform.position.y = Target.position.y + distanceFromPlayer*1.5;
 
  }
 
 }
 
 
 
 function SetTarget (t : Transform)
 
 {
 
     Target = t;
 
 }

Any idea? Greets

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

Answer by syclamoth · Nov 27, 2011 at 01:23 AM

How about adding this one thing to your camera script? Just after it gets network instantiated.

 if(!networkView.isMine)
 {
     camera.enabled = false;
 }

Otherwise, make sure that the 'Main Camera' gets disabled on clients, or renders behind the other cameras (which isn't a fantastic way of blocking it, but will still work).

Comment
Add comment · Show 2 · 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 Tomate · Nov 28, 2011 at 12:05 AM 0
Share

So I should not use the $$anonymous$$ainCamera, but a different Camera for Clients? Host can use $$anonymous$$ainCamera?

avatar image syclamoth · Nov 28, 2011 at 01:50 AM 0
Share

Well, you can use what you want- I usually just move the main camera around independently (as in, I don't synchronise it at all) so that all players just use that. Remember that if an object doesn't have a network view, it can be wherever it likes! However, in your question you said you were instantiating new cameras for every player- which is why I told you to disable the main camera (since the newly instantiated cameras on the players would interfere with it otherwise)

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

Unity networking tutorial? 6 Answers

Multiplayer camera switch issue 0 Answers

How do I make sure that the camera's target is the cloned player that is created when a player joins the server? 1 Answer

Assign spawned object to SmoothFollow target 1 Answer

Multiplayer Client Missing Reference To Spawn Object 1 Answer


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