# Rotate object the same amount as the motion controller is rotating (object stays in place)

Hello everybody. I am bad at Math (too bad for development) and i am having a problem with this simple(?) problem. Let’s say there is a safe or some other similar object and player would need to rotate the handle. What i want is, when player interacts with the object, it would start rotating same amount as the motion controller is rotated, while player is in interacting mode.

I looked up the tutorial series that i found here. There were many interactions, but i could not find this one. I guess, it would be simple, if i understood the Cos/Sin easily, but for now, i’m not so good with them. Any idea where to start cracking this? Any help would be appreciated! Thanks.

Got it working while messing this morning. It was rather simple. What i did was take the current rotation of the motion controller just after interacting. Then constantly do Vector - Vector (on roll) and create a rotation based on that. Now that i have angle between current rotation and begin rotation i just feeded them into the actor i wanted. In actor, we first take the current rotation and then combine the new rotation to it. We use Rinterp, so the rotation stops after it succeeds.

Of course, this graph is horrible. We should maybe use interfaces to do this. We should not get all actors of class, but maybe set the actor variable after it overlaps the motion controller, or something like that. However, you get the picture what this is aiming for, right :).

You can always get forward vector of controller then calculate “look at rotation” of [0,0,0] to forward vector.
To get only horizontal plane rotation, you can multiply forward vector by [1,1,0] then normalize it after.
Or you can project vector on a plane.

Ok i read post, you want to rotate knob on safe. Use controller right or up vector. Project it onto knob plane. Then normalize. Then make find look at rotation [0,0,0] to that normalized vector. You should get controller rotation projected onto knob plane. Now split that rotation, pick correct angle and add to angle of knob rotation (clamp it), then rotate knob.