Hi, I am trying to move an actor (camera on dolly) to match a location/rotation defined by another actor (Dolly Target).
The movement and matching of the final position works fine but during the movement the actor (camera dolly) does an almost full rotation before matching
the final position.
I am guessing I somehow need to force it to take the shortest rotation possible to the final position or somehow keep it facing the right direction as it moves, I want
the actor to face towards the direction of movement/final position as best as possible.
Can anyone suggest how I can achieve this?
By the way the (camera on dolly) is not an actual camera, just a model of a camera I want to move around a scene.
OK, so what is happening is the relative rotation z is going from x to y, moving z degrees. So 20 to 340 = 320 degrees of movement instead of 20 to -20, 40 degrees of movement you want. You never want to have more than 180 degrees of movement from point a to b. So x-y = absolute(w) (change this to always be a positive by getting the absolute) w now equals 0 to 360. If(w > 180){if(x <= y){true y = y-360, false y = y+360}
Now, I don’t have unreal open in front of me while I type this so I can’t try out the move Component to node, but it might not except a number less than 0 or greater than 360. If this is the case, use the tick event and FinterpToConstant with cameraOndolly.rotation.z in current and y plugged into the target except with one other node between them. Drag off the float pin and start typing in rotate. One of the options that comes up returns a float between 0 and 360 for the float. I can’t remember exactly what it is called. Anyway, if y+360 = 400 and you current rotation is 355. Your interp will return a number between 355 and 400 but the node changes any number above 360 into a degree. Lets look at this with some real numbers.
CameraOndolly.RelativeRotation.z (x in the equations) will be the rotation we want to update. It is currently at 222.
Dollytarget.Rotation.z (y in the equations) is the target rotation. The target rotation = 17.
222
-17
=205 (w in the equations)
205 > 180 = true
205 <= 17 = false
17 + 360 = 377
On tick > FInterpToConstant
Current 205
target 377
return(“Result” somewhere between 205 and 377)
Result [goes into the node I can’t remember, let’s call it returnAnAngle] returnAnAngle(Result) will return a number between 0 and 360.
Set cameraOndolly.relativeRotation.z to returnAnAngle(Result)
Thanks for your help - very thorough. I think I understand your equation and it seems to make sense to solve my problem but being fairly new to blueprints I am having trouble implementing your equation in BP form, what nodes/functions to use etc.
Could you show me this in blueprint form? Thanks again, appreciate it!
There are float * float math operators and >, <, == boolean operators. Just use the context sensitive search and you should find em no problem. And try the “RInterpTo” node for rotations