If my character is standing still facing forward, and with a single S (backwards) key press I’d want it to rotate backwards, how would I get the logic for that? I can’t get speed since it starts walking right as I click the key, how would I distinguish between walking and just pressing the key once?
So just to make sure I’m understanding correctly.
Currently when you press S your character walks backwards.
Your desired results are for your character to turn around when you Press S but move when you hold it?
Correct me if im wrong.
My character tries to turn backwards, but just pressing once only turns it a little bit, so it’s not an immediate rotation, which is what I want (I want it to rotate right away in a smooth animation rather than gradually rotating depending on how much of the key you press).
Ah i see. so you want the character to rotate a full rotation on key press no matter how long you hold the key.
This should be what you are looking for.
Create a timeline. open the timeline and create a float track. add one point with a time and value of 0 and another point with a time and value of 1. I have called my track “Curve 0-1 1s”.
Then take your current rotation and your target rotation and Lerp it with your created track as the alpha and set the actor rotation!
May I ask where did you get your Current and your Target?
current and target are variables I create. Current id there just to represent the storing of current rotation. if you wanted to get the current rotation you could just use get actor rotation.
target is the desired rotation. which in your case would be current rotation +180 degrees in in the appropriate axis.
There’s an issue with it though, when clicking the key, it doesn’t stop when reaching the other side, it spasms a bit and just goes everywhere, also, it raises a problem, because I only want it to do this when my character is standing still, when I’m running, I don’t want this to activate.
Here’s a video of the bug:
If anyone knows of any other way to solve this issue, I’d be much appreciated.
Thanks, but wouldn’t this bring the standing still vs moving problem up again?
Before you start walking check if you are rotated the right way; if not, rotate.
I meant when I’m normally sprinting and when I press the backwards key, I don’t want it to do all this logic, I’d wager it would have something to do with velocity?
Last bump on this, still trying to achieve the effect, I know a lot of games using UE4 that have this problem fixed so I’m surprised there aren’t more people asking about it.
That is because most people making a game know some programming logic.
What you want to do is this: find if actor is sprinting, then use a branch. If the character is sprinting (true) do nothing. If the caracter is not sprinting (false), do beanswaggle’s logic.
Good luck and let us know if you get it working the way you want!
It isn’t a matter of just some “programming logic” though, else you’d see this problem get called up on more.
I don’t have any sprint mechanic in the game, the character simply walks, and when you hit any movement key, the speed value goes up to the max, so there’s no simple way of knowing if the character is walking or is simply trying to turn backwards.