void OnGUI() { if (interactionSystem == null) { return; } if (GUILayout.Button("Start Interaction With " + interactionObject.name)) { if (effectors.Length == 0) { Debug.Log("Please select the effectors to interact with."); } foreach (FullBodyBipedEffector e in effectors) { interactionSystem.StartInteraction(e, interactionObject, true); } } if (effectors.Length == 0) { return; } if (interactionSystem.IsPaused(effectors[0])) { if (GUILayout.Button("Resume Interaction With " + interactionObject.name)) { interactionSystem.ResumeAll(); } } }
// GUI for calling the interactions void OnGUI() { interrupt = GUILayout.Toggle(interrupt, "Interrupt"); // While seated if (isSitting) { if (!interactionSystem.inInteraction && GUILayout.Button("Stand Up")) { interactionSystem.ResumeAll(); isSitting = false; } return; } // While standing if (GUILayout.Button("Pick Up Ball")) { interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, ball, interrupt); } if (GUILayout.Button("Button Left Hand")) { interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, button, interrupt); } if (GUILayout.Button("Button Right Hand")) { interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, button, interrupt); } if (GUILayout.Button("Put Out Cigarette")) { interactionSystem.StartInteraction(FullBodyBipedEffector.RightFoot, cigarette, interrupt); } if (GUILayout.Button("Open Door")) { interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, door, interrupt); } // This is a multiple-effector interaction if (!interactionSystem.inInteraction && GUILayout.Button("Sit Down")) { interactionSystem.StartInteraction(FullBodyBipedEffector.Body, benchMain, interrupt); interactionSystem.StartInteraction(FullBodyBipedEffector.LeftThigh, benchMain, interrupt); interactionSystem.StartInteraction(FullBodyBipedEffector.RightThigh, benchMain, interrupt); interactionSystem.StartInteraction(FullBodyBipedEffector.LeftFoot, benchMain, interrupt); interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, benchHands, interrupt); interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, benchHands, interrupt); isSitting = true; } }
void Update() { // sitting.RunButtCheck(); interactionSystem.ik.solver.rightLegChain.bendConstraint.weight = interactionSystem.ik.solver.bodyEffector.positionWeight; interactionSystem.ik.solver.leftLegChain.bendConstraint.weight = interactionSystem.ik.solver.bodyEffector.positionWeight; if (isSitting) { if (!interactionSystem.inInteraction && Input.GetButtonDown("WXButton1")) { interactionSystem.ResumeAll(); isSitting = false; } return; } if (!interactionSystem.inInteraction && Input.GetButtonDown("WXButton1")) { print("test"); sitting.RunButtCheck(); //Body interactionSystem.StartInteraction(FullBodyBipedEffector.Body, sittingMain, interrupt); //Left Leg //interactionSystem.StartInteraction(FullBodyBipedEffector.LeftThigh, sittingMain, interrupt); interactionSystem.ik.solver.leftLegChain.bendConstraint.bendGoal = leftThighBendTarget; interactionSystem.ik.solver.leftLegChain.bendConstraint.weight = interactionSystem.ik.solver.bodyEffector.positionWeight; //Right Leg //interactionSystem.StartInteraction(FullBodyBipedEffector.RightThigh, sittingMain, interrupt); interactionSystem.ik.solver.rightLegChain.bendConstraint.bendGoal = rightThighBendTarget; interactionSystem.ik.solver.rightLegChain.bendConstraint.weight = interactionSystem.ik.solver.bodyEffector.positionWeight; //Left Hand interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, sittingLeftHand, interrupt); //RightnHand interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, sittingRightHand, interrupt); //interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, benchHands, interrupt); isSitting = true; } }
// Triggering the interactions void OnGUI() { // If jumping or falling, do nothing //if (!character.onGround) return; // If an interaction is paused, resume on user input if (interactionSystem.IsPaused() && interactionSystem.IsInSync()) { GUILayout.Label("Press E to resume interaction"); if (Input.GetKey(KeyCode.E)) { interactionSystem.ResumeAll(); } return; } // If not paused, find the closest InteractionTrigger that the character is in contact with int closestTriggerIndex = interactionSystem.GetClosestTriggerIndex(); if (Input.GetKey(KeyCode.L)) { print(closestTriggerIndex); } // ...if none found, do nothing if (closestTriggerIndex == -1) { return; } // ...if the effectors associated with the trigger are in interaction, do nothing if (!interactionSystem.TriggerEffectorsReady(closestTriggerIndex)) { return; } // Its OK now to start the trigger GUILayout.Label("Press E to start interaction"); if (Input.GetKey(KeyCode.E) || (Input.GetButton("L2"))) { interactionSystem.TriggerInteraction(closestTriggerIndex, false); } }
public void LetGo() { interactionSystem.ResumeAll(); // the actual letting go of the object holdPoint.position = holdPointOriginal.position; slerpValue = 0; }