Smoothing a rotation

Hello,

i create a rotator out of 2 dynamic floats which depends on the mouse input, but unfortunately it isnt smooth and keeps jumping pixels especially at slow mouse input. I heard about RInterpTo but i dont know what to do with the ‘target rotation’ pin i only want to get a smooth rotation.

Hi ejakulatje,

I’m not home with my computer but I can link you my blueprints tomorrow !

The target rotation is the rotation you want to end up having.

I know but I just want to smooth out the rotation. And because of the dynamic rotation value.

@Crowly_Caine… interesting, this would be really useful, but I’m wondering how it works?

as far as I can tell, on Tick, it jumps instantly (interp speed of 0) to the target length and doesn’t interpolate at all

Target rotation is your goal rotation. So if you want smooth rotation, you need something like this:

With your camera. But this won’t work, if you you are using control rotation.

Using something similar to zoom my camera in and out “smoothly”. It is somewhat inefficient and ideally you’d have a custom event set up to update it rather than event tick.

Should be possible to adapt to rotation.

Heh should give thanks to the OP, since I was reading this question, it made me realize I should just remake it right now:

There, no event tick, only updates when I actually zoom. However since you’re gonna be rotating the camera a lot I suppose it wouldn’t be a big deal using event tick but… might as well not if you can avoid it.

You’re completely right about that actually, I stopped using the interp speed because I handled the smoothness with the camera sensitivity variable instead which gave the desired result. Thanks for pointing that out so I can chuck it out of the event, I had completely forgotten.

The reason this works in its current form is because of the nature of a scroll wheel. You either let it spin, which makes it smooth no matter what, or you move it by increments, in which case you just need to “hide” the chopping with a low sensitivity.

Actually, further to your comment there, I decided to make this so that a single button press sets your zoom distance and interps smoothly between two options. I made a simple function in the character blueprint:

Then set the values by key presses, updating the time and checking every tick if the camera distance is at the desired zoom distance. If it is not, it runs the function:

Again, not super efficient with the event ticks, but it gives a really nice result and you can change the speed of the interpolation to get the desired effect. This should be easily adaptable to rotation.

If you wanted to do this via scroll wheel it would look like this:

In this case the camera sensitivity and the interp speed are the key things you want to fiddle around with to get something you’re happy with.

Again though… event tick for something that only updates when you press the keys, better handled by events. It does add a really professional feel to the camera movement though.

I’m sorry for taking this so far off topic btw, hopefully this gives the OP some ideas on how he can achieve what he is trying to achieve.

My code i currently looking like this but i still dont know which target rotation to put in?

I am currently using the attached script but i still dont which target rotation to put in?

Well you need to set a current rotation. In the start of whatever else happens in your function, you need to set a what the current rotation is at the start of your movement so it has something to rotate from. The movement you perform then becomes your target rotation.

If you need help with the RInterp to, check out Mathew Wadstein who is part of Epic Staff, he makes great videos of various functions and breaks them down really nicely:


I shamelessly stole my zoom in/out from him.

Yes, as @Crowley Cain says… you could use a Rinterp and definitely check out Matt Wadstein’s YouTube tutorials on Rinterp and Lerp (he’s a great resource for learning stuff generally)

you can also use a Lerp driven by a timeline… to interpolate between your current and target rotation using an alpha value