private void Update() { CalculateVelocity(); HandleWallSliding(); playerMotor.Move(velocity * Time.fixedDeltaTime, verticalInput); //Deten el movimiento si está en el suelo o tocando algo arriba. if (playerMotor.collisionInfo.above || playerMotor.collisionInfo.below) { if (playerMotor.collisionInfo.isSlidingDownMaxSlope) { velocity.y += playerMotor.collisionInfo.slopeNormal.y * -gravity * Time.deltaTime; } else { velocity.y = 0; } } //Animation stuff if (velocity.x != 0) { spriteRenderer.flipX = velocity.x < 0; } animator.SetBool("grounded", playerMotor.collisionInfo.below); animator.SetFloat("velocityX", Mathf.Abs(targetVelocityX)); }
public void _Update(float timeStep) { // read input from input driver Vector2 input = new Vector2(m_InputDriver.Horizontal, m_InputDriver.Vertical); Vector3 velocity = new Vector3(input.x, input.y, 0) * m_Movement.Speed; m_Motor.Move(velocity); }