I’m trying to rotate the character to look where the camera is facing. I made it work but it’s a bit jittery (as you can see in the GIF below). How would I make it smoothly rotate?
Try RenderStepped. Heartbeat is in sync with framerate after physics update while RenderStepped deals with rendering before hearbeat does, so using the latter in this case would be helpful.
I wouldn’t suggest TweenService for something like this, since you’d have to create an entire new Tween every frame. Lerping with an Alpha of about .6 should do the trick.
How would lerping work if I’m calculating a new CF every frame? If I set the alpha to 0.6, wouldn’t that just rotate the character 60% of the way? I’m not sure how that would fix the jittering.
No, it’s not, did you mean to write something else than “server”? The only difference between Heartbeat/RenderStepped/Stepped is where in the frame they run, they have the same frequency (once per frame). Heartbeat on the client doesn’t run “in sync with the server”.
I recommend you put a BodyGyro in the HumanoidRootPart and update its CFrame on RenderStep. Limit the MaxTorque so that it can only rotate about the y-axis. The benefit to using a BodyGyro is that it handles the interpolation for you with easily customizable settings for torque and dampening.
I’ve already gotten it to work by directly setting the CFrame of the Hrp. I’ve tried lerping and using BodyGyro before, but I just don’t like the feel of it. I prefer instantly setting it in this case. But thanks!
I worded that wrong. To quote zeuxcg, “Since our camera scripts run at RenderStepped, if your updates depend on camera in some way - e.g. you want to keep some object fixed relatively to camera - you’d have to run the updates in RenderStepped to avoid a single-frame lag. Other than that I don’t see a strong use case for RenderStepped.”
Essentially you would want to use RenderStepped for things linked to camera rendering (like this) since it runs camera/rending things before physics, it goes first in the order. (as opposed to Heartbeat).
I will correct the original post however.
One useful tip @Spynaz is to use :BindToRenderStep() since you can keep the events firing in sync using the RenderPriority parameter.