Multiplayer Camera Problem! Help me plase
Help me I'm trying to make multiplayer fps game but the players are looking at the same camera! I'm tried Brackeys's code but the host player is can't see because its camera is deactivated!
Answer by Joey_pc · Aug 30, 2017 at 05:00 PM
you can do 2 things here
1- create a new camera and deactivate the standby camera (locally only)
2- put deactivated camera on the world and enable it when you join to the server and disable the standby camera
if you need a code you can watch this series episode by episode
https://www.youtube.com/watch?v=AIgwZK151-A
Answer by Unitykullanici · Aug 30, 2017 at 05:05 PM
@Joey_pc when i make this players are looking at the same cam!
Answer by lll4louis · Jun 30, 2018 at 08:34 AM
I had this problem before, and soon I find out that you should not put the camera into the Player.
and in this camera, I make two script for it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace S3
{
public class CameraFollow : MonoBehaviour
{
public Transform playerTransform;
public int depth = 0;
// Update is called once per frame
void Update()
{
if (playerTransform != null)
{
transform.position = playerTransform.position + new Vector3(0, 0, depth);
}
}
public void setTarget(Transform target)
{
playerTransform = target;
}
}
}
and the next script
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
namespace S3
{
public class CameraController : NetworkBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
float x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f;
float z = Input.GetAxis("Vertical") * Time.deltaTime * 3.0f;
transform.Rotate(0, x, 0);
transform.Translate(0, 0, z);
}
}
}
so, it will become a FPS game, hope it works.