Hi everyone, I’m looking in the rotation and got an issue that complicates things where it might not. By using the scroll mouse, I want to yaw rotate an actor of (+ or -) 60 degrees. I use SetActorRotation & and a timeline to have an interpolation. The issue is that I can set a value from -179.999 to +179.999. When I’m at 180 and want to go to 240 it goes to -120 instead thus rotate backward to -120. What is the correct way to do this?
It’s because you’re splitting the rotation.
If you do the lerp with rotation values the node can handle it, without the jumping at 180.
Also, using ‘get actor rotation’ during the TL won’t help. You have to store the actor rotation before you go into the TL
In short, something like
You are specifically saying actor (not character), but for your info the character movement component has rotation smoothing built in. Afaik it does not have angle clamping built in. Spring arms also have smoothing options.
What @ClockworkOcean shows looks fine except that at the start (assumingly when you scroll that mouse wheel) it uses the current actor rotation, so this changes the intended “set rotation” behavior to a “add rotation” behavior, where a desired step or range will not be respected. If this is exactly what you want (rotate in steps of X degrees) then I misunderstood and this is perfect but you must ensure you play the entire timeline and not quit / restart halfway interpolation as that would rotate you by a wrong amount.
If you’re looking for a kind of movement like a stationary security camera which can rotate within a certain range then:
Instead of using the actor’s yaw, you should store a float variable of the yaw you currently added through scrolling which clamps between -180 and 180 or any other desired range, then interpolate the current value to the new value (when you scroll again).
Lastly I do prefer to use Tick myself for interpolating in these situations. You will always end up on the value you cache as “target rotation” on your class as long as the actor is ticking, with no concerns about playing one or multiple timelines for all interpolations you might need. Tick is not expensive on this. On tick instead of an alpha (0 - 1) you’d get from a timeline you could instead also interpolate by X degrees * delta time
Well spotted Roy, I didn’t read it closely enough
Thank you guys! To make the rotation snappier here is what I ended up with and I guess I could simplify it a bit more…
I think you’ll still find it will work better if you fix the ‘from’ before you use the TL.
At the moment, you’re chasing your own tail, because the lerp is trying to organize things for you, but the actor rotation is changing during that process…
Yes I know what you mean but I want the player to see the full rotation that have been asked and not just take the shortest path so I need to use the current rotation. I think I will still need to work it a bit but it’s already way easier to work with the rotations .
Yes, current rotation when you start the TL
You will end up with an incorrect calculation if you sample it during. Up to you, though…
If you want to sample it during the process, you can use an rinterptoconst node, but that works on tick and not a TL.
I updated the image to avoid the tile chasing itself
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.