Make backwards movement slower

Hello
I am currently trying to make a top-down shooter but I’ve run into an issue

What i want is to make the character run slower when running sideways or backwards

When the character is only moving the character automatically faces to the direction of movement (ideally to go top speed)

8648-ezgif-save(2).gif

but when the player is shooting (i.e. clicking) the character always faces the cursor

8649-ezgif-save(3).gif

I have my scripts in the player controller but i’m not sure if they should be there or in the character blueprint…

What I am looking for is a way to make sideways movement slower (like 0.8x) and backwards movement slower (like 0.5x)… but I could not find where to start

I was thinking in limiting it in the blueprint by mapping the angle to the cursor (0…180 deg) to a speed value (1…0.5) and setting the character movement max speed to that, but I think it is a hacky way and I think there should be a better way

I was also thinking I should subclass the CharacterMovement component in c++ and add my custom behavior there, I think this should be a better way as it would separate things more correctly… but again I don’t know if it is possible or how to do it.

Is it any other way to get what I want? What would be the better way to accomplish this?

you could reference the GetForwardVector and GetRightVector. Then change the groundspeed when those are active. So if GetForward is <0 then Set Groundspeed. And if GetRight is != 0 then Set Groundspeed. Of course you would also have to check these with a bool and make sure that normal forward is set back.

Maybe this will help anyone who comes across this in the future.

So the little dot is a “Dot Product” and the highlighted nodes are the ones that turn forward movement into a positive number and back movement into negative number.

2 Likes