I’m trying to make a blueprint that rotates something X degrees over X time. Once it reaches it, it can either do it again immediately (so it spins constantly) or it can pause for X time before doing it again.
I started by using RInterpTo Constant and Set Actor Rotation. This works on the Z-Axis, but the X-Axis doesn’t move at all and the Y-Axis stops after 90 degrees and starts jittering. I’ve done some research and everyone says to use Add Local Rotation instead… but that doesn’t do the same thing so I don’t see how that’s a solution. When I tried that, my actor spun around at super speed because it’s not interpolating any more.
I tried to use interp to find where it should be at the end of the function and subtract the current rotation from that, giving me the correct rotation to add, but to my surprise, you can’t just do math with rotators like you can with vectors. I have no clue what I should do. Rotators seem so limited that I can’t really do anything with them. I’ve heard that Quats are better but I can’t seem to do anything with those, either.
This one is the workaround that I found online, but it isn’t interpolating between the starting rotation and the target rotation, it’s just adding the target to the current every frame, which is an entirely different thing:
If you want to do X degrees over X time, I’d would go for a timeline.
It will work if you calculate the start and end points before using the TL.
You calculate the end point using either delta( rotator ) or combine( rotator ).
As you’ve discovered, the another option, is only adding local rotation.
If you want to be able to do any kind of rotations using any method ( TL / interp ) without having to worry about weird transforms, then you need quaternions.
But how can I use quaternions? there’s the To Quaternion node, but once I have one, it seems I’m not really able to do anything with it. I’m trying to avoid Timelines because this will all be in C++ in the end, and I don’t think timelines are a thing in C++, are they?
Combine rotator adds them together, right? how do I subtract?
This is how I’m trying to rotate a simple mesh. I’m making a component that can be attached to meshes to make them rotate. The one that isn’t working is a fan. The fan is upright and the player is supposed to run between the blades as it spins, but it won’t spin right. It will only rotate on the Z-Axis. I don’t want to just add to the rotation because that makes it spin super fast and I can’t track where it is. Interpolating allows me to set a target and do something when it reaches it (i.e. spin 90 degrees, then stop). It also allows me to control the exact amount of time it takes to rotate. As far as I can tell, RInterpTo Constant is the only way to do that.
You can also do this with the addition of rotations and a timeline. I will have a go if you upload it. Or just show a pic with the pivot clearly, and I’ll make something similar
But yeah the best may be with quaternions which could require C++ but you can also do completely arbitrary axes.
Quaternion has a function to go from axis angle representation to quat. Axis can be just X, Y, or Z, or something completely arbitrary that points in any direction. It’s basically a normalized direction vector.
You can then animate the rotation on its own in whatever way you want.
Then set the object’s quat from that angle that is animated and the axis you choose.
It makes sense that you’re having issues with Rotators because of how they work and gimbal lock.