I am working on a headtracking script and would like some feedback on how I can improve the current implementation. Here is a minimal file with only bare-bones headtracking (everything is in ServerScriptService):
LookatThingy.rbxl (22.5 KB)
A general overview of the code is that PerspectiveLookerClientUpdater calculates your camera angle every Heartbeat and reports that to PerspectiveLookClientService. PerspectiveLookClientService uses what it’s received from the Updater to calculate and set the waist and neck Transform properties to orientate the character towards where the camera is looking. For some additional context, the reason for the split between these two scripts is for a separate replicator script and other integrations that are not included in the attached file.
I am generally satisfied with all of the scripts in this file aside from PerspectiveLookClientService. I imagine some of what I use for angle math is superfluous, and am also not sure the comments convey the need for and what the two hacks in the file do. I am open to comments regarding things other than those two as well though.