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 BEFORE the state's update function. This is run regardless of what state you're in. protected override void EarlyGlobalSuperUpdate() { bool acquiringGround = superCharacterController.currentGround.IsGrounded(false, 0.01f); bool maintainingGround = superCharacterController.currentGround.IsGrounded(true, 0.5f); if (acquiringGround) { rpgCharacterController.StartAction("AcquiringGround"); } else { rpgCharacterController.EndAction("AcquiringGround"); } if (maintainingGround) { rpgCharacterController.StartAction("MaintainingGround"); } else { rpgCharacterController.EndAction("MaintainingGround"); } }
/// <summary> /// Input abstraction for easier asset updates using outside control schemes. /// </summary> private void Inputs() { try { inputAttackL = rpgInputs.RPGCharacter.AttackL.WasPressedThisFrame(); inputAttackR = rpgInputs.RPGCharacter.AttackR.WasPressedThisFrame(); inputBlock = rpgInputs.RPGCharacter.Block.IsPressed(); inputCastL = rpgInputs.RPGCharacter.CastL.WasPressedThisFrame(); inputCastR = rpgInputs.RPGCharacter.CastR.WasPressedThisFrame(); inputDeath = rpgInputs.RPGCharacter.Death.WasPressedThisFrame(); inputFace = rpgInputs.RPGCharacter.Face.IsPressed(); inputFacing = rpgInputs.RPGCharacter.Facing.ReadValue <Vector2>(); inputJump = rpgInputs.RPGCharacter.Jump.WasPressedThisFrame(); inputLightHit = rpgInputs.RPGCharacter.LightHit.WasPressedThisFrame(); inputMovement = rpgInputs.RPGCharacter.Move.ReadValue <Vector2>(); inputRelax = rpgInputs.RPGCharacter.Relax.WasPressedThisFrame(); inputRoll = rpgInputs.RPGCharacter.Roll.WasPressedThisFrame(); inputShield = rpgInputs.RPGCharacter.Shield.WasPressedThisFrame(); inputAim = rpgInputs.RPGCharacter.Aim.IsPressed(); inputSwitchDown = rpgInputs.RPGCharacter.WeaponDown.WasPressedThisFrame(); inputSwitchLeft = rpgInputs.RPGCharacter.WeaponLeft.WasPressedThisFrame(); inputSwitchRight = rpgInputs.RPGCharacter.WeaponRight.WasPressedThisFrame(); inputSwitchUp = rpgInputs.RPGCharacter.WeaponUp.WasPressedThisFrame(); // Injury toggle. if (Keyboard.current.iKey.wasPressedThisFrame) { if (rpgCharacterController.CanStartAction("Injure")) { rpgCharacterController.StartAction("Injure"); } else if (rpgCharacterController.CanEndAction("Injure")) { rpgCharacterController.EndAction("Injure"); } } // Headlook toggle. if (Keyboard.current.lKey.wasPressedThisFrame) { rpgCharacterController.ToggleHeadlook(); } // Slow time toggle. if (Keyboard.current.tKey.wasPressedThisFrame) { if (rpgCharacterController.CanStartAction("SlowTime")) { rpgCharacterController.StartAction("SlowTime", 0.125f); } else if (rpgCharacterController.CanEndAction("SlowTime")) { rpgCharacterController.EndAction("SlowTime"); } } // Pause toggle. if (Keyboard.current.pKey.wasPressedThisFrame) { if (rpgCharacterController.CanStartAction("SlowTime")) { rpgCharacterController.StartAction("SlowTime", 0f); } else if (rpgCharacterController.CanEndAction("SlowTime")) { rpgCharacterController.EndAction("SlowTime"); } } } catch (System.Exception) { Debug.LogError("Inputs not found! Character must have Player Input component."); } }
private void Sprinting() { if (rpgCharacterController.hasNoWeapon) { bool useSprint = GUI.Toggle(new Rect(640, 115, 100, 30), rpgCharacterController.isSprinting, "Sprint"); if (useSprint && rpgCharacterController.CanStartAction("Sprint")) { rpgCharacterController.StartAction("Sprint"); } else if (!useSprint && rpgCharacterController.CanEndAction("Sprint")) { rpgCharacterController.EndAction("Sprint"); } } }
/// <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"); inputCastL = Input.GetButtonDown("CastL"); inputCastR = Input.GetButtonDown("CastR"); inputSwitchUpDown = Input.GetAxisRaw("SwitchUpDown"); inputSwitchLeftRight = Input.GetAxisRaw("SwitchLeftRight"); inputAimBlock = Input.GetAxisRaw("Aim"); inputAiming = Input.GetButton("Aiming"); inputHorizontal = Input.GetAxisRaw("Horizontal"); inputVertical = Input.GetAxisRaw("Vertical"); inputFace = Input.GetMouseButton(1); inputFacingHorizontal = Input.GetAxisRaw("FacingHorizontal"); inputFacingVertical = Input.GetAxisRaw("FacingVertical"); inputRoll = Input.GetButtonDown("L3"); inputShield = Input.GetButtonDown("Shield"); inputRelax = Input.GetButtonDown("Relax"); // Injury toggle. if (Input.GetKeyDown(KeyCode.I)) { if (rpgCharacterController.CanStartAction("Injure")) { rpgCharacterController.StartAction("Injure"); } else if (rpgCharacterController.CanEndAction("Injure")) { rpgCharacterController.EndAction("Injure"); } } // Headlook toggle. if (Input.GetKeyDown(KeyCode.L)) { rpgCharacterController.ToggleHeadlook(); } // 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!"); } }