Smooth rotation on button clicked

Hello everyone!
I am having trouble trying to get my character facing forwards smoothly.

As you may see in the video, when I am facing backwards, and try to walk forwards, the character rotates smoothly, but when I shoot, the character just immediately facing forwards. I want it to be smooth like in the walking rotation.

For the function of the shooting I set “Use controller rotation yaw” to true, and when I release the button it is set back to false. This is how I ensure the character will always face forwards, but I was wondering if there is any other way to do that because it is not giving the result I wanted.

Thank you!

Hey there, you can’t really do that because you’ll get that pop. When you shoot you need to get the control rotation and extract the yaw and interpolate it along time.

How do I do that?

Something like this, might have some bugs, but overall it works.

Wow. Thank you. I will test it out once I get home

I’ve got this working on my character. It will smoothly rotate the character for you.

Your problem is that you’re setting UseControllerRotationYaw immediately. What you want to do is set UseControllerDesiredRotation and set a bool (i.e. “TurningInPlace”) to true. And in your tick function, you want to do this

In my game, at the point where I turn UseControllerRotationYaw on, he is in an aiming state (rifle raised). With client/server, rotation isn’t smoothed on the clients so you would have to do that yourself if you need it. Also, you can control the rotation rate.with SetRotationRate.

I think that’s it.

What did you put as a value in the target yaw? I dont really understand.

I set it with the yaw of the control rotation, the control rotation in your case tells you where the camera is looking at.

How do you do that? I am a beginner so sorry for all of those questions :stuck_out_tongue:

It doesnt work

Yeah it does. I’m using it. If it’s not working for you then you need to be more specific. Show me what you did.

Oh wait. That’s not quite my code. Mine is more complex because I consider that the player may start moving before the turn is complete. I tried to simplify it to make it easier on you. So I included the UseControllerRotationYaw by mistake. You can probably just drop that node – though it should still have worked, he just would have been locked to the camera at the end.

I removed that now and the character doesnt rotate at all.

What about the first part? Where the aim button is pressed and you start the turn? Show me that please.

Just follow what i did in the image above.

But I dont want to do it when he jumps. I want to do it when he shoots

Its the same thing… just replace the input to be the shoot action mapping.

Its not working…

Oh nvm it works! Thank you!