Prevent "clamping" of movement vectors in ACharacter?

Hi guys!

New to UE4 here, but reasonably experienced (5 years) in C++.

I’ve been having a blast mucking around with the C++ FPS example.

I would like to implement straferunning such that if I hold down forwards + strafe-right or forwards + strafe-left I will travel diagonally
at a greater speed than either of the directions individually. Or put simply: I want to add the forwards movement vector and strafe
movement vector together. As it currently looks, ACharacter will ensure the maximum length of any direction isn’t exceeded.

I tried uncapping the maximum walking speed, but that results in the character performing the same behaviour as before - just at a
higher velocity.

I’m assuming I may need to override UCharacterMovementComponent and set it to be used by my ACharacter via an ObjectInitializer,
but I really wouldn’t know what to do from there. The class is huge and overriding functions willy-nilly doesn’t seem like a good approach.

Any advice is much appreciated!


I’d just add a bool bIsSkying, set it to true if both axis value are > 0, false if not.
if (bIsSkying) { MovementComponent->MaxWalkSpeed = float YourDesiredSPeed;} else { MovementComponent->MaxWalkSpeed = float NormalSpeed;}

Sorry if it’s dumb answer, i’m a rooky.

No such thing as a dumb suggestion!

That is certainly a valid solution and one that I’ll probably use for the short term just so I can focus on prototyping gameplay elements out, but ultimately in the long term I would like the physics engine to accommodate it “naturally”

Thanks for your reply though!

Well, don’t forget to update this thread then! :slight_smile: