Hi, I’m trying to get my player to fly up and down on the z axis, however when it hits the minimum or maximum position it stops moving. How can I get it to work with my constraints.
My function looks like:
void UCustomMovementComponent::MoveUp(float AxisValue)
{
You could just call GetOwner()->AddActorLocalOffset() outside the if check, that way the delta location will only update whilst the condition is true, otherwise, it will use the last valid value.
Another way would be to use FMath::Clamp which will lock a value between a min and max range and remove the IF check altogether.
Thank you, however moving the local offset out of the if statement doesn’t work. Then the clamp causes it to just fly up because the Axis value is used for the input so its either 1, 0 or -1.