Networking a gamePlayer prefab with the camera, both clients use the same camera?
Hey, so I've been trying to get the networking for a project up and running, however this problem has been holding me back. My GamePlayer prefab is a parent of my camera, each time the client enters the hosts game, the host uses the clients camera. I've tried every single answer forum that I was able to find and none have worked for me yet. I'm currently working with just some simple movement code on a tutorial prefab.
The movement script I have on my player model is...
void Update()
{
//verifies local player status if...
if (!isLocalPlayer)
{
//this command returns to the original status if is-Not-LocalPlayer is = to true
return;
}
//Allows movemnet on the specified axis
var x = Input.GetAxis ("Horizontal") * Time.deltaTime * 150.0f; //This code will allow movement on the x axis
var z = Input.GetAxis ("Vertical") * Time.deltaTime * 3.0f;//This code will allow movement on the y axis
transform.Rotate (0, x, 0);
transform.Translate (0, 0, z);
}
public override void OnStartLocalPlayer() //When local player stats...
{
GetComponent<MeshRenderer> ().material.color = Color.blue; //Change material to blue for identification purposes
}
}
The child of my playermodel, which is also my camera has this script...
public Camera myCam;
// void Start () {
// if (!isLocalPlayer) //verifies local player status
// GetComponent<Camera> ().enabled = false; //Turns off the Camera within the myCam on non-LocalPlayer, GamePlayer prefabs
// }
void Update () {
if (!isLocalPlayer)
myCam.enabled = false;
return;
}
}
The commented out code is just a different approach which was suggested to me, I've only commented it out for now. If you have any ideas or suggestions that code help it'd be greatly appreaciated.
Your answer
Follow this Question
Related Questions
How to make the ball follow the cursor? 0 Answers
Camera following on Green and Red Axis 0 Answers
Camera zoom out on follow 1 Answer
Camera always behind player 0 Answers
Camera yMin postion should be restricted to player postion 1 Answer