IntendToMoveRight does not work

hi developers, i have a serious problem with tank’s sideway movement and i can not figure it out.
the problem is Ben did set “CurrentThrottle” at SetThrottle function like this:

void UTrack::setThrottle(float throttle) {///called from blueprint
	//UE_LOG(LogTemp, Warning, TEXT("throttle is %f"), throttle)
	currentThrottle = FMath::Clamp<float>(throttle + currentThrottle, -1, 1);
	//currentThrottle = throttle;
}

i really cant understand the reason of setting “CurrentThrottle” like that.(if anyone know that please share the reason with me)
and the other problem is i tried to set “CurrentThrottle” like the way we did before.

currentThrottle = throttle;

the result was Tank never moved sideway at all(but with setting throttle like how Ben did it works perfectly)
and the other thing about this behavior that makes me wonder is i tried to log the “CurrentThrottle” at “Driving” function and again the result for moving forward is predictable(-1, +1 , 0) but its always 0.000 for moving right.
as i understand when i press “Right/Left” button first things first Blueprints set the controller for keyboard and then we use it to modify IntendToMoveForward/Right like this:


so when we use the result in C++ function of IntendToMoveRight it should be alright(and it is).
but why when “Driving” function calls from OnHit(…) function CurrentThrottle is always 0 for side ways movement and its alright for forward movement?
thank you.

It’s being used as a percentage of the max speed. So with a digital signal like a keyboard it’s either 1, 0, or -1 (through the input binding).

Would need to see your code and input bindings.

1 Like

@DanM
thanks Dan, but my question is why we didnt set it just like before.
like this i mean : currentThrottle = throttle;
and we set it like this : currentThrottle = FMath::Clamp(throttle + currentThrottle, -1, 1);
note : i know why we used Clamp<> but my question is why we set currentThrottle by adding throttle to last frame’s currentThrottle?

i mean every frame we can set currentThrottle with throttle amount that we get it from setThrottle() function? cant we ?

Then you would be tying the movement to the frame rate which is not something you want to do.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms