public void OnSceneLoad() { PlayerObject_1 = GameObject.FindGameObjectWithTag("P1Object"); PlayerObject_2 = GameObject.FindGameObjectWithTag("P2Object"); for (int i = 0; i < 5; ++i) { if (!(controller.Joystick_Player_Map.ContainsKey(i))) { continue; } Controller_Management_Behaviour.PlayerInfo info = controller.Joystick_Player_Map[i]; if (info.PlayerNo == 0) { info.playerObject = PlayerObject_1; } if (info.PlayerNo == 1) { info.playerObject = PlayerObject_2; } } }
// Update is called once per frame void Update() { for (int i = 0; i < 5; ++i) { if (!(controller.Joystick_Player_Map.ContainsKey(i))) { continue; } Controller_Management_Behaviour.PlayerInfo info = controller.Joystick_Player_Map[i]; if (info.playerObject == null) { OnSceneLoad(); } GameObject PS4_Player = info.playerObject; float LShorizontal = Input.GetAxis("LS_Horizontal_" + i.ToString()); //LSHorizontal pos = LS pushed right, neg = LS pushed Left float LSvertical = Input.GetAxis("LS_Vertical_" + i.ToString()); //LSVertical pos = LS pushed up, neg = LS pushed down, float RShorizontal = Input.GetAxis("RS_Horizontal_" + i.ToString()); //RSHorizontal pos = RS pushed right, neg = RS pushed Left float RSvertical = Input.GetAxis("RS_Vertical_" + i.ToString()); //RSVertical pos = RS pushed up, neg = RS pushed down, //bool BTNfire1; //if (Input.GetButtonDown("Fire1_" + i.ToString())) //Fire1 button is Circle //{ // BTNfire1 = true; //} //else //{ // BTNfire1 = false; //} bool BTNjump; if (Input.GetButtonDown("Jump_" + i.ToString())) //Jump button is Cross { BTNjump = true; } else { BTNjump = false; } InputPacket ctrl_arr = new InputPacket(LShorizontal, LSvertical, RShorizontal, RSvertical, BTNjump); PS4_Player.SendMessage("processInput", ctrl_arr); if (Input.GetButtonDown("Options_" + i.ToString())) { PS4_Player.SendMessage("OnStart"); } } }