- Home /
Problem with character controlling with photon cloud
Hello everyone, I'm creating a multiplayer game with photon, and i made this script to each controlable character for every person connected to a server... But the problem is that everyone can control all the players and not each player control his player...
Script: using UnityEngine; using System.Collections;
public class FirstPersonNetwork : Photon.MonoBehaviour {
MouseLook cameraScript;
CharacterMotor controllerScript;
FPSInputController controllerScript2;
CharacterController charControl;
GameObject cam;
public void Awake()
{
cameraScript = GetComponent<MouseLook>();
controllerScript = GetComponent<CharacterMotor>();
controllerScript2 = GetComponent<FPSInputController>();
charControl = GetComponent<CharacterController>();
}
public void Start()
{
if (photonView.isMine)
{
//MINE: local player, simply enable the local scripts
cameraScript.enabled = true;
controllerScript.enabled = true;
controllerScript2.enabled = true;
charControl.enabled = true;
}
else
{
enabled = true;
cameraScript.enabled = true;
controllerScript.enabled = true;
controllerScript2.enabled = true;
charControl.enabled = true;
}
controllerScript.SetIsRemotePlayer(!photonView.isMine);
controllerScript2.SetIsRemotePlayer(!photonView.isMine);
gameObject.name = gameObject.name + photonView.viewID;
Screen.lockCursor = true;
}
public void Update()
{
if (Input.GetKeyDown (KeyCode.C))
{
Screen.lockCursor = !Screen.lockCursor;
}
}
}
This is the editor preview with the object (PlayerUnityEngineer) which needs to be controlable:
If someone knows how to solve this problem, please help me by answering my question :) Thanks,
Basilic Apps
Answer by asdf123 · Aug 25, 2014 at 02:40 AM
If you checked the script 2 or 3 times before you post here a question you would see that on:
if (photonView.isMine)
{
//MINE: local player, simply enable the local scripts
cameraScript.enabled = true;
controllerScript.enabled = true;
controllerScript2.enabled = true;
charControl.enabled = true;
}
else
{
enabled = true;
cameraScript.enabled = true;
controllerScript.enabled = true;
controllerScript2.enabled = true;
charControl.enabled = true;
}
its all set to true, change that for the following code:
if (photonView.isMine)
{
//MINE: local player, simply enable the local scripts
cameraScript.enabled = true;
controllerScript.enabled = true;
controllerScript2.enabled = true;
charControl.enabled = true;
}
else
{
enabled = true;
cameraScript.enabled = false;
controllerScript.enabled = false;
controllerScript2.enabled = false;
charControl.enabled = false;
}
I've already tried this but now players are not seeing the right camera but they control the right character. Why ?
Your answer
Follow this Question
Related Questions
Photon Cloud max players 1 Answer
A node in a childnode? 1 Answer
Cannot see other player in Multipayer Project? 0 Answers
Photon Cloud doesn't work correctly 3 Answers
Unity List? 1 Answer