- Home /
Photon characters control wrong player
My code: public bool CanMove = true; Camera camera; public GameObject PlayerPref; public PhotonView view; public float FasterSpeed = 20f; public float JumpHeight; public float Speed = 10f; public CharacterController controller; public bool IsGrounded; public Transform Groundcheck; public LayerMask Ground; public float Gravity = -9.2f; private Vector2 velocity;
public float groundDistance; private Vector2 SmoothMove; // Start is called before the first frame update void Start() { view = GetComponent(); camera = GetComponentInChildren();
}
// Update is called once per frame
private void Moving() { IsGrounded = Physics.CheckSphere(Groundcheck.position,groundDistance,Ground); float x = Input.GetAxis("Horizontal"); float z = Input.GetAxis("Vertical"); Vector3 move = transform.right x + transform.forward z; controller.Move(move Speed Time.deltaTime); controller.Move(velocity Time.deltaTime); if (IsGrounded && velocity.y < 0f) { velocity.y = -2f; } if(Input.GetKey(KeyCode.LeftShift) && IsGrounded) { Speed = FasterSpeed; }else { Speed = 18f; } if (Input.GetButtonDown("Jump")&& IsGrounded) { velocity.y += Mathf.Sqrt(JumpHeight -2 Gravity); } velocity.y += Gravity Time.deltaTime; }
public void Update()
{
if (view.IsMine){
Moving();
}else
{
if (!view.IsMine && GetComponent<PlayerMovement>() != null)
{
Destroy(GetComponent<PlayerMovement>());
}
}
Please help bc player 1 is controlling player 2. And everything works fine until player 2 comes
Answer by AbdeCodeEnjoyer · Oct 20, 2021 at 03:56 AM
It is indeed very messy, all i can maybe say is to be sure that each client use PhotonNetwork.Instantiate on their on code.
Your answer

Follow this Question
Related Questions
Webcam Unity 3.5 not working on Android? 0 Answers
GrayscaleEffect shader broken in 3.5? 0 Answers
Error with Camera.allCameras on building flash build for unity 3.5 0 Answers
'text' is not a member of 'OBJECT' JavaScript Not Working in Unity 3.5 - Lost Commands? 2 Answers
Unity 3.5 w/android&IOS vs 4.0 free? 1 Answer