private void Attacks() { if (!rpgCharacterController.CanStartAction("Attack")) { return; } if (rpgCharacterController.leftWeapon == (int)Weapon.Unarmed) { if (GUI.Button(new Rect(25, 85, 100, 30), "Attack L")) { rpgCharacterController.StartAction("Attack", new Actions.AttackContext("Attack", "Left")); } } if (rpgCharacterController.rightWeapon == (int)Weapon.Unarmed) { if (GUI.Button(new Rect(130, 85, 100, 30), "Attack R")) { rpgCharacterController.StartAction("Attack", new Actions.AttackContext("Attack", "Right")); } } if (rpgCharacterController.hasTwoHandedWeapon) { if (GUI.Button(new Rect(130, 85, 100, 30), "Attack")) { rpgCharacterController.StartAction("Attack", new Actions.AttackContext("Attack", "None")); } } }
/// <summary> /// Input abstraction for easier asset updates using outside control schemes. /// </summary> private void Inputs() { try { inputJump = Input.GetButtonDown("Jump"); isJumpHeld = Input.GetButton("Jump"); inputLightHit = Input.GetButtonDown("LightHit"); inputDeath = Input.GetButtonDown("Death"); inputAttackL = Input.GetButtonDown("AttackL"); inputAttackR = Input.GetButtonDown("AttackR"); inputSwitchUpDown = Input.GetAxisRaw("SwitchUpDown"); inputAim = Input.GetAxisRaw("Aim"); inputAiming = Input.GetButton("Aiming"); inputHorizontal = Input.GetAxisRaw("Horizontal"); inputVertical = Input.GetAxisRaw("Vertical"); inputRoll = Input.GetButtonDown("L3"); // Injury toggle. if (Input.GetKeyDown(KeyCode.I)) { if (rpgCharacterController.CanStartAction("Injure")) { rpgCharacterController.StartAction("Injure"); } else if (rpgCharacterController.CanEndAction("Injure")) { rpgCharacterController.EndAction("Injure"); } } // Slow time toggle. if (Input.GetKeyDown(KeyCode.T)) { if (rpgCharacterController.CanStartAction("SlowTime")) { rpgCharacterController.StartAction("SlowTime", 0.125f); } else if (rpgCharacterController.CanEndAction("SlowTime")) { rpgCharacterController.EndAction("SlowTime"); } } // Pause toggle. if (Input.GetKeyDown(KeyCode.P)) { if (rpgCharacterController.CanStartAction("SlowTime")) { rpgCharacterController.StartAction("SlowTime", 0f); } else if (rpgCharacterController.CanEndAction("SlowTime")) { rpgCharacterController.EndAction("SlowTime"); } } } catch (System.Exception) { Debug.LogError("Inputs not found!"); } }
void Update() { if (character != null) { RPGCharacterController controller = character.GetComponent <RPGCharacterController>(); controller.SetJumpInput(Vector3.up); if (controller.CanStartAction("Jump")) { controller.StartAction("Jump"); } } }
// Put any code in here you want to run AFTER the state's update function. This is run regardless of what state you're in. protected override void LateGlobalSuperUpdate() { // If the movement controller itself is disabled, this shouldn't run. if (!enabled) { return; } // Move the player by our velocity every frame. transform.position += currentVelocity * superCharacterController.deltaTime; // If alive and is moving, set animator. if (!rpgCharacterController.isDead && rpgCharacterController.canMove) { if (currentVelocity.magnitude > 0f) { animator.SetFloat("Velocity X", 0); animator.SetFloat("Velocity Z", transform.InverseTransformDirection(currentVelocity).z *movementAnimationMultiplier); animator.SetBool("Moving", true); } else { animator.SetFloat("Velocity X", 0f); animator.SetFloat("Velocity Z", 0f); animator.SetBool("Moving", false); } } // Strafing. if (rpgCharacterController.isStrafing) { RotateTowardsTarget(rpgCharacterController.aimInput); } else if (rpgCharacterController.canMove) { RotateTowardsMovementDir(); } if (currentState == null && rpgCharacterController.CanStartAction("Idle")) { rpgCharacterController.StartAction("Idle"); } // Update animator with local movement values. animator.SetFloat("Velocity X", transform.InverseTransformDirection(currentVelocity).x *movementAnimationMultiplier); animator.SetFloat("Velocity Z", transform.InverseTransformDirection(currentVelocity).z *movementAnimationMultiplier); }