void Update() { if (m_state != m_nextState) { eState prevState = m_state; m_state = m_nextState; if (OnStateChanged != null) { OnStateChanged(this, prevState, m_state); } } if (State != eState.Dying) { if (m_platformDropTimer > 0f) { m_platformDropTimer -= Time.deltaTime; if (m_platformDropTimer <= 0f) { // Restore the One Way Down collision again after the time is over m_smartRectCollider.OneWayCollisionDown = m_savedOneWayCollisionDown; } } // This timer allow to jump during a while if smart collider is not grounded if (m_fallingJumpToleranceTimer > 0f) { m_fallingJumpToleranceTimer -= Time.deltaTime; } if (m_platformDropTimer <= 0f) { if (VPad.IsActionDrop()) { StopClimbing(); // Allow the smart collider to go down by temporary disabling the One Way Down collision. It will be restored after the time is over. m_savedOneWayCollisionDown = m_smartRectCollider.OneWayCollisionDown; //NOTE: for this to work, OneWayCollisionDown should be removed from LayerCollisions m_smartRectCollider.LayerCollision = m_smartRectCollider.LayerCollision & ~m_smartRectCollider.OneWayCollisionDown; m_smartRectCollider.OneWayCollisionDown = 0; m_platformDropTimer = PlatformDropTime * transform.localScale.y; } else if ((VPad.IsActionJump()) && m_jumpReleased && (m_isGrounded || m_isSwimming || m_isClimbing || m_fallingJumpToleranceTimer > 0)) { StopClimbing(); m_jumpSpeed = (m_isSwimming? SwimmingJumpSpeed : JumpSpeed) * Mathf.Clamp01(1 - m_rigidBody2D.drag * JumpDragFactor * Time.deltaTime); m_jumpReleased = false; } } if (VPad.IsActionJumpUp()) { m_jumpReleased = true; if (m_jumpSpeed > CutJumpSpeedLimit) { m_jumpSpeed = CutJumpSpeedLimit; } } } }