Turn in place with A and D buttons.

Hello everyone, can someone help me out how to setup turn in place states in my state machine?
I need to setup next logic when i click and hold middle mouse button and press A or press and hold A it turn character to the left, and same for D key for right like in this GIF.
2024-05-21 04-18-26
And if i just press press A or D key turn character in place+playercamera should follow turn rotation like in this GIF.
As you can see, if i press A or D and fast release the key it does small turn in place, as i counted in game, it takes 20 fast key presses (18º) to do 360º rotation, and 10 if i do complete key press (36º)
2024-05-21 04-18-26(1)
And finally when i press W+A or W+D it should run in circle as in this GIF.
2024-05-21 04-18-26(2)
Here is how i tried to implement the functionality from the above using ChatGPT:)



I also created 2 states for turn left and turn right in my state machine

But it seems they don’t work, and the functions from Character blueprint are overriding them or something like that.

2024-05-22 20-19-06

Here is the GIF of how it works now, as you can see at the beginning when i hold right mouse click my character moves to left and right as i need, and then i just press and hold A or D and character is moving with glitched turn in place movement, instead of turning in place. And finally by the end of the gif you can see how i click and release D key fast, character is turning in place 18º and when it reaches 180º it rotates back to 0

Well as a TA solving your problem is difficult with out access to the project files as the solution usually depends on what is available but maybe to set you on the right path maybe a few bullet points based on concepts would help. Based on the second example Ilm assuming your using in-place so feet sliding is a common problem so I’ll stick to that as root motion is a different subject.

A misconception is that the animation (in-plqce) controls movement behaviour in world space but in fact is only a visual representation of the current state of the movement component as to referencing world space. That is to say that the movement components movement is constant as to velocity as in if you press the A key the MC rotation will be a constant rotation clock wise which will in turn trigger the turn in place animation relative to the world space rotation.

You solve this problem by quickly pressing the turn in place keys which is starting and stopping the MC’s rotation in the desired direction so that would be the kind of trigger behaviour you would feed into the movement component.

The bullet point to remember is in-palce animation data always reference world space velocity where human based movement “always” references the ground where the velocity is “not” a constant.

There are a few Youtube videos on the subject but for what seems to be a simple problem is rather complex in practice and the solution will most likely be one that works.

A tip.

The most common solution I’ve seen is to counter the velocity of the MC by back keying the in-place relative to the ground and planted foot and then play catch up.

You could also try sync markers and sync groups

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.