I figured I should take a stab at making a simple “Top Down Shooter” (WASD + Mouse) a’la Alien Swarm or Crimson Land in basic movement. For now, I just tied X and Y speed to input Axis which I tied to WASD.
Up and Right (for example) will result in max speed up and max speed right, which is super speed diagonally. A classical input problem, but I’m not sure how to deal with it in Blueprints?
But more than that, maybe this is not a good way to go about it. Is it wiser to use a Direction for the CharacterMovement and only use velocity for it? And then potentially rotate the mesh towards the “crosshair” for strafing, etc.
Thoughts overall on how to approach this would be appreciated.
I don’t have the editor open at the moment, but there should be a ClampVectorSize node or something along those lines. Just clamp your velocity vector to your desired max speed and it will the work for you.
Well, anwsered in the first part, I guess. Should work and we kinda standard for those kind of problems.
for 1. you can combine both input, get the vector, normalize the vector and then multiply against maxspeed to get your velocity vector.
Even though it looks like independent event in UE4, but for input I think it’s a mix of polling and event.
if you want to have different speed(ie move forward is faster, move back while shooting is slower), then it’s better to let your crosshair decides your yaw rotation.
(I think there is a node to the let rotate character to lookAt certain point.)
You can always interpolate with a given rotation speed limit. (it’s in character class already for maximum turn rate.)
I have a similar kind of movement system that uses Add Movement Input node. This should give you correct speed while moving diagonally. Here’s my setup:
I control my character through player controller blueprint. Inside my character blueprint I have a box that covers my whole camera view and I line trace against this box to get my mouse location. This way I can get more steady control on uneven terrain.