// Use this for initialization void Start() { if (!isLocalPlayer) { return; } player = Player.instance; if (player == null) { Debug.LogError("No Player instance found in map."); Destroy(this.gameObject); return; } leftHand = player.leftHand; rightHand = player.rightHand; if (leftHand != null) { refLeft = leftHand.gameObject.GetComponent <HandleControllersButtons>(); // Get the reference of "HandleControllerButtons" script. "HandleControllerButtons" script updates the buttons state. } if (rightHand != null) { refRight = rightHand.gameObject.GetComponent <HandleControllersButtons>(); } }
// Use this for initialization void Start() { hand = gameObject.GetComponent <Hand>(); handleButtons = this; }
// Update is called once per frame void Update() { if (!isLocalPlayer) { return; } if (leftHand == null) { leftHand = player.leftHand; } if (rightHand == null) { rightHand = player.rightHand; } refLeft = player.leftHand.gameObject.GetComponent <HandleControllersButtons>(); refRight = player.rightHand.gameObject.GetComponent <HandleControllersButtons>(); lTrigger = refLeft.GetTriggerPress(); lA = refLeft.GetAPress(); lApp = refLeft.GetAppPress(); lGrip = refLeft.GetGripPress(); rTrigger = refRight.GetTriggerPress(); rA = refRight.GetAPress(); rApp = refRight.GetAppPress(); rGrip = refRight.GetGripPress(); bimanual = false; lockCombination = 0; if (lTrigger && rTrigger) { bimanual = true; } if (bimanual) { if (lA && rA) { lockCombination += 1; } if (lApp && rApp) { lockCombination += 3; } if (lGrip && rGrip) { lockCombination += 5; } } else { if (lTrigger) { if (lA) { lockCombination += 1; } if (lApp) { lockCombination += 3; } if (lGrip) { lockCombination += 5; } } else if (rTrigger) { if (rA) { lockCombination += 1; } if (rApp) { lockCombination += 3; } if (rGrip) { lockCombination += 5; } } } CmdSyncButtons(lTrigger, rTrigger, lA, rA, lApp, rApp, lGrip, rGrip); CmdUpdateActions(bimanual, lockCombination); }