Unity Photon Networking Buttons ~ HELP,
Hi everyone, I am doing a mobile multiplayer game project. I can conncet players and also I can play multiplayer in my computer but problem occurs when I want to move players with buttons I can just control one player(With buttons if I open game from test editor and normal editor, buttons do not work) So How can I control both players with Buttons. I am bringing my movement code;
using Photon.Pun; using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerAnimatorManager : MonoBehaviourPun {
public float speed = 10f;
public float rotspeed = 10f;
Rigidbody rbTank;
public static float forwardBack;
public static float leftRight;
bool forward = false;
bool left = false;
bool back = false;
bool right = false;
void Awake() { rbTank = GetComponent (); }
public void Start() { enabled = photonView.IsMine; }
public void Forward() { if (photonView.IsMine == false && PhotonNetwork.IsConnected == true) { return; } forward = true; }
public void Back() { if (photonView.IsMine == false && PhotonNetwork.IsConnected == true) { return; } back = true; }
public void Left() { if (photonView.IsMine == false && PhotonNetwork.IsConnected == true) { return; } left = true; }
public void Right() { if (photonView.IsMine == false && PhotonNetwork.IsConnected == true) { return; } right = true; }
// Update is called once per frame void Update() { if (photonView.IsMine == false && PhotonNetwork.IsConnected == true) { return; } forwardBack = Input.GetAxis("Vertical") speed Time.deltaTime; leftRight = Input.GetAxis("Horizontal") rotspeed Time.deltaTime; if (forward == true) { forwardBack = -1f; } if (back == true) { forwardBack = 1f; } if (left == true) { leftRight = -1f; } if (right == true) { leftRight = 1f; } }
void FixedUpdate() { TankForwardBack(); TankRotateleftRight(); } void TankForwardBack() { Vector3 moveFB = transform.forward forwardBack speed Time.deltaTime; rbTank.MovePosition(rbTank.position + moveFB); } void TankRotateleftRight() { Quaternion rotateLR = Quaternion.Euler(0f, leftRight, 0f); rbTank.MoveRotation(rbTank.rotation rotateLR); } public void SwitchBoolsOff() { forward = false; back = false; left = false; right = false; } } I am waiting your comments pls help me.,