Nothing special about my code, but im trying to find a way to make it so that my character can only run forward as he sprints. I’ve tried putting the code in my MoveRight() function in an if statement that is called when isSprinting is false but that just makes it an error. Below is my code for my sprint function, what should i add to only allow forward movement?
And here is my MoveForward and MoveRight functions
void ABaseHero::MoveForward(float Value)
{
if (isSprinting && Value < 0)
{
AddMovementInput(GetActorForwardVector(), Value * 0.5);
}
else
{
AddMovementInput(GetActorForwardVector(), Value);
}
}
void ABaseHero::MoveRight(float Value)
{
if (isSprinting)
{
AddMovementInput(GetActorRightVector(), Value * 0.5);
}
else
{
AddMovementInput(GetActorRightVector(), Value);
}
}
TO BE CLEAR. I know I shouldn’t have hard coded the 0.5 in there, but that is just my temporary solution. I will most likely replace that with WalkSpeed ÷ RunSpeed.