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 /
  • Help Room /
avatar image
0
Question by Agent-6141 · Jun 07, 2018 at 11:26 PM · multiplayerclientcamera followcamera viewporthost

Multiplayer Camera Follow. Please Help Im so Close!!

Problem:

I start two clients, one is a host/client and the other is just a client. When the game starts the two players spawn in. The camera then locks on to the second client player (nonhost) and displays on both clients. I have spent 18 hours on this and have not figured it out. I have setup everything else correctly. Each character moves independently, but the camera will just not split.

Goal:

I start two clients, one is a host/client and the other is just a client. When the game starts the two players spawn in. Each client has a separate camera.

Layout:

One camera object in scene tagged as "MainCamera" starting as "active" along with the camera component "enabled."

Bellow is the script I have attached to my camera and the script I have attached to my player prefab.

Camera Script:

 using UnityEngine.Networking;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityStandardAssets.Characters.ThirdPerson;
 
 
 public class CameraControl : MonoBehaviour
 {
     
     private const float Y_ANGLE_MIN = 0.0f;
     private const float Y_ANGLE_MAX = 50.0f;
     
     public Transform camTransform;
     public float distance = 5.0f;
     public Transform lookAt;
     private float currentX = 0.0f;
     private float currentY = 45.0f;
     private float sensitivityX = 4.0f;
     private float sensitivityY = 1.0f;
 
     private void Start()
     {
         camTransform = transform;
     }
 
     private void Update()
     {
         currentX += Input.GetAxis("Mouse X");
         currentY += Input.GetAxis("Mouse Y");
 
         currentY = Mathf.Clamp(currentY, Y_ANGLE_MIN, Y_ANGLE_MAX);
        
         
     }
 
     private void LateUpdate()
     {
         Vector3 dir = new Vector3(0, 0, -distance);
         Quaternion rotation = Quaternion.Euler(currentY, currentX, 0);
         camTransform.position = lookAt.transform.position + rotation * dir;
         camTransform.LookAt(lookAt.transform.position);
     }
 }
 

Player Prefab Script:

using UnityEngine.Networking; using UnityStandardAssets.Characters.ThirdPerson; using UnityEngine; using System.Collections;

public class LocalPlayerControl : NetworkBehaviour {

 private GameObject cameraObject;
 private void Start()
 {

     cameraObject = GameObject.FindGameObjectWithTag("MainCamera");

     if (isLocalPlayer)

     

     GetComponent<ThirdPersonUserControl>().enabled = true;
     GetComponent<ThirdPersonCharacter>().enabled = true;
     GetComponent<Animator>().enabled = true;
     GetComponent<CapsuleCollider>().enabled = true;
     GetComponent<AudioSource>().enabled = true;
     GetComponent<NetworkAnimator>().enabled = true;
     GetComponent<NetworkTransform>().enabled = true;
     cameraObject.GetComponent<CameraControl>().enabled = true;
     cameraObject.GetComponent<CameraControl>().lookAt = GameObject.FindGameObjectWithTag("Player").transform;
     cameraObject.GetComponent<Camera>().enabled = true;
    // cameraObject.GetComponent<CameraControl>().camTransform = transform;


 }

}

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

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.

Follow this Question

Answers Answers and Comments

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

Trying to send command for object without authority 0 Answers

Giving authority to clients 0 Answers

HELP Network spawn player (host or client) in same position 0 Answers

Remote clients can no longer connect with new modem / router 0 Answers

Spawning GameObject on network, locally change it only on the client that spawned it. 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