Change pawn movement speed

IIRC The input vectors are normally used only to determine direction. They are normalized and all movement is then applied in the resulting direction.

Is there any specific reason you are inheriting from UPawnMovementComponent? Without knowing much about your project I would say you should instead inherit from UFloatingPawnMovement.

Using UFloatingPawnMovement exposes variables like Acceleration and Max Speed.

Looking a little more at your code when you consume the input vector you use:

ConsumeInputVector().GetClampedToMaxSize(1.0f) * DeltaTime * 150.0f;

If it wasn’t normalizing the vector before it is definitely normalized after GetClampedToMaxSize(1.0f).

I haven’t read the code for UPawnMovementComponent, so I am not certain if it does the normalization itself. Either way, for the sake of code organization I believe it would be better not to try to tell the movement component how fast to go through the input vectors. This could give rise to strange problems like if you set up two methods of control WASD and arrow keys a player could move twice as fast by pressing W and the up arrow.

You could expose your own variable on your UPaddlePawnMovementComponent that represents speed and then multiply the vector by that instead. Then you could do something like:

ConsumeInputVector().GetClampedToMaxSize(1.0f) * DeltaTime * Speed;

1 Like