void Update() { if (!_enableMove) { if (!_motor.frozen) { _motor.frozen = true; } return; } else { if (_motor.frozen) { _motor.frozen = false; } } // use last state to restore some ladder specific values if (_motor.motorState != PlatformerMotor2D.MotorState.FreedomState) { // try to restore, sometimes states are a bit messy because change too much in one frame FreedomStateRestore(_motor); } // Jump? // If you want to jump in ladders, leave it here, otherwise move it down if (Input.GetButtonDown(PC2D.Input.JUMP)) { _motor.Jump(); _motor.DisableRestrictedArea(); if (_motor.IsOnLadder()) { _motor.LadderAreaExit(); } } _motor.jumpingHeld = Input.GetButton(PC2D.Input.JUMP); // XY freedom movement if (_motor.motorState == PlatformerMotor2D.MotorState.FreedomState) { _motor.normalizedXMovement = Input.GetAxis(PC2D.Input.HORIZONTAL); _motor.normalizedYMovement = Input.GetAxis(PC2D.Input.VERTICAL); return; // do nothing more } // X axis movement if (Mathf.Abs(Input.GetAxis(PC2D.Input.HORIZONTAL)) > PC2D.Globals.INPUT_THRESHOLD) { _motor.normalizedXMovement = Input.GetAxis(PC2D.Input.HORIZONTAL); } else { _motor.normalizedXMovement = 0; } if (Input.GetAxis(PC2D.Input.VERTICAL) != 0) { bool up_pressed = Input.GetAxis(PC2D.Input.VERTICAL) > 0; if (_motor.IsOnLadder()) { if ( (up_pressed && _motor.ladderZone == PlatformerMotor2D.LadderZone.Top) || (!up_pressed && _motor.ladderZone == PlatformerMotor2D.LadderZone.Bottom) ) { // do nothing! } // if player hit up, while on the top do not enter in freeMode or a nasty short jump occurs else { // example ladder behaviour _motor.FreedomStateEnter(); // enter freedomState to disable gravity _motor.EnableRestrictedArea(); // movements is retricted to a specific sprite bounds // now disable OWP completely in a "trasactional way" FreedomStateSave(_motor); _motor.enableOneWayPlatforms = false; _motor.oneWayPlatformsAreWalls = false; // start XY movement _motor.normalizedXMovement = Input.GetAxis(PC2D.Input.HORIZONTAL); _motor.normalizedYMovement = Input.GetAxis(PC2D.Input.VERTICAL); } } } else if (Input.GetAxis(PC2D.Input.VERTICAL) < -PC2D.Globals.FAST_FALL_THRESHOLD) { _motor.fallFast = false; } if (Input.GetKeyDown(PC2D.Input.START_SLIDE)) { //m_Animator.SetTrigger("slide"); m_Animator.Play("PlayerSlide"); _motor.Dash(); } if (Input.GetKeyDown(PC2D.Input.WAVE_SWORD)) { _motor.Wave(); if (_motor.motorState == PlatformerMotor2D.MotorState.JumpWave) { m_Animator.SetTrigger("jumpWave"); } else { m_Animator.SetTrigger("wave"); } meleeAttack.gameObject.SetActive(true); } if (Input.GetKeyUp(PC2D.Input.WAVE_SWORD)) { meleeAttack.gameObject.SetActive(false); meleeAttack.DisableDamage(); } if (Input.GetKeyDown(PC2D.Input.THROW_DAGGER)) { _motor.Throw(); if (_motor.motorState == PlatformerMotor2D.MotorState.JumpThrow) { m_Animator.SetTrigger("jumpThrow"); } else { m_Animator.SetTrigger("throw"); } } }