Hello, i’m trying to do that
"Using what you have learned, try to do the following:
Implement directional controls that increase speed after being held for a certain period of time."
It is one of those things that at the end of tutorial we should try to do.
I thought to declare two variable , int holding and float speed.
So i have write these two functions
void AMyPawn::VelocityHold()
{
holding++;
}
void AMyPawn::VelocityStop()
{
holding = 0;
}
and in void AMyPawn::tick i have write this
if (holding > 3)
{
speed = 9000.0f;
}
else
{
speed = 1.0f;
}
// Handle movement based on our "MoveX" and "MoveY" axes
{
if (!CurrentVelocity.IsZero())
{
CurrentVelocity = CurrentVelocity * speed;
FVector NewLocation = GetActorLocation() + (CurrentVelocity * DeltaTime );
SetActorLocation(NewLocation);
}
}
the character moves the same as before.
The input command are bound so
InputComponent->BindAction("Velocity", IE_Pressed, this, &AMyPawn::VelocityHold);
InputComponent->BindAction("Velocity", IE_Released, this, &AMyPawn::VelocityStop);
help me to fix, thanks to all