public override void UpdateAction(float deltaTime) { normalizedSpeed.x = input.Value().x; normalizedSpeed = Vector2.ClampMagnitude(normalizedSpeed, 1); smoothedMovementFactor = controllableCharacter.IsGrounded() ? groundDamping : inAirDamping; velocity = controllableCharacter.GetVelocity(); velocity.x = Mathf.Lerp(velocity.x, normalizedSpeed.x * moveSpeed, deltaTime * smoothedMovementFactor); velocity.x = controllableCharacter.GetCollisionState().Left&& velocity.x < 0 ? 0 : velocity.x; velocity.x = controllableCharacter.GetCollisionState().Right&& velocity.x > 0 ? 0 : velocity.x; controllableCharacter.SetVelocity(velocity); }
public override void UpdateAction(float deltaTime) { newDirection = input.Value(); if (newDirection != currentAimingDirection && newDirection != Vector2.zero) { CalculateNewAimingAngle(newDirection); } if (!canAimBelownWhileGrounded && controllableCharacter.GetStateMachine().Equals((int)CharacterState.grounded)) { currentAimingDirection = previousDirection; } Debug.DrawRay(transform.position, currentAimingDirection * 2f, Color.yellow); }