Adding Dashing
Introduction
Adding Dashing
private void CustomActivity()
{
MovementActivity();
DashActivity();
}private void DashActivity()
{
if (BoostInput?.WasJustPressed == true)
{
float magnitude = MovementInput?.Magnitude ?? 0;
bool isHoldingDirection = magnitude > 0;
if (isHoldingDirection)
{
// dividing by magnitude tells us what X and Y would
// be if the user were holding the input all the way in
// the current direction.
float normalizedX = MovementInput.X / magnitude;
float normalizedY = MovementInput.Y / magnitude;
XVelocity = normalizedX * DashSpeed;
YVelocity = normalizedY * DashSpeed;
}
}
}
Limiting Dash Frequency

Adding a Cooldown Indicator

Defining States





Using States in code

Changing Player Colors

You just made a game!
Last updated
Was this helpful?



