Motor6D.Transform rotation based on camera rotation

So, I’m trying to smoothly rotate the players UpperTorso and Head based on their camera angle using Motor6D.Transform, however I’m having two problems.

Firstly, I don’t know how to get the rotation of the camera, I tried using LookVector which gave some strange results.

Secondly, I’m trying to use a .Stepped function to update the Motor6D.Transforms by having a RemoteFunction send over the angles, however I can’t find a way to invoke this RemoteFunction x times a second to create a smooth looking rotation.



The LookVector is only a part of the rotation, if you need the complete rotation you need the entire CFrame. You also probably want to skip the remotes and keep it completely clientside.

1 Like

Someone asked about making a character’s head look at the camera, and I have an answer here:

This will get you most of the way there, but because you are using Transform instead of DesiredAngle, the final solution will involve some more vector math.

The second part of the problem, replication, will come in one of two forms: either not an issue (if roblox’s network ownership sends the data to the other clients), or even more complicated than getting the torso to turn (if it doesn’t send the data to other clients).

If it does not send the data to other clients, you will have these problems:

  • Latency will make direct application of the Transform jerky and not smooth
  • To combat latency, the rotation must be interpolated between the previous state and the new, replicated state
  • Every client will be required to do this for every other client

The rotational portion of a CFrame ‘cf’ would be (cf - cf.p)** You just subtract away the translation component, and what you’re left with is just the rotation components.

RemoteEvent handlers essentially have their own pseudo-thread, not in sync with Stepped, so you have to cache the value and process it on RunService.Stepped. If your client sends a RemoteEvent at a fixed rate, just be aware that this nice spacing of events is not going to be exactly preserved because of The Interwebs, but you can sequentially number the outgoing events and always overwrite with the latest at the receiving end. I don’t know off hand if the RemoteEvent system already does anything internally to guarantee relative ordering of events, but raw UDP doesn’t so I’ve had to do this sort of thing on other platforms.

** CFrame.p is now CFrame.Position, with the shorthand version being officially deprecated, but impossible to remove without breaking literally every game, so safe to use.