I created a multiplayer game with pun2 (Photon Unity Networking) but when I move and look actually changes of my character will apply to other characters, also when my friends move their changes will apply to my character
void Update(){
isGrounded = Physic.CheckSqhere(groundCheck.position,groundDistance, LayeMask);
if (isGrounded && velocity.y<0)
{
velocity.y=-1f;
}
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
if (Input.GetButtonDown("Jump") && isGrounded)
{
velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
}
Vector3 Movement = transform.right * x * transform.forward *z;
if (isGrounded)
{
characterController.Move(Movement * speed * Time.deltaTime)
}
else{
characterController.Move(Movement * speedOnJumping * Time.deltaTime)
}
velocity.y +=gravity * Time.deltaTime;
characterController.Move(velocity * Time.deltaTime);}
and
void Start(){
PhotonNetwork.ConnectUsingsettings();
}
public override void onConnectedToMaster(){
PhotonNetwork. AutomaticallySyncScene = true;
createButton.onclick.AddListener(()=>{
PhotonNetwork.createRoom("Amin's Room");
});
joinButton.onclick.AddListener(()=>{
PhotonNetwork.JoinRoom("Amin'sRoom");
});
base.OnConnectedToMaster();
}
public override void OnJoinedRoom(){
if (PhotonNetwork.IsMasterClient){
Debug.Log("you are the master");
PhotonNetwork.LoadLevel(1);
}
base.OnJoined Room();
}