Expression must have arithmetic, unscoped enum, or pointer type error. Please Help.

​​​​So I don’t want the character to be able to sprint: Left; Right, Diagonal Bottom Right, Diagonal Bottom Left or backwards. So I tried to get the character velocity and disable the sprintSpeedMultiplier which is set to 2 and multiplies the max walk speed. (divides the max walk speed when shift is no longer held) But I got this error while in the if statement and also I don’t know how to do the stop sprinting left right etc. Any help would be amazing. Thanks.

It looks like MoveForward is a function. You can’t compare a function to a float value, unless that function returns float. But than again, that would be MoveForward() and not simply MoveForward. Anyways, your current solution wouldn’t work as the player’s velocity is in world coordinates. If you think about it, all you have to do is check if the W key is held down along with the shift key. I assume you have Input set up similar to this: “MoveForward” with W being 1, and S being -1. So if you get the value of that input somehow (AActor::GetInputAxisValue seems to do just that) you can compare against that.



// Assuming this function is called when you press the sprint key.
void ANinja::Sprint()
{
    if (GetInputAxisValue(TEXT("MoveForward")) > 0)
    {
        sprintSpeedMultiplier = true;
    }
}