Camera Rotation Limit [SOLVED]


I don’t know how to explain so here’s a video.

I want the character to be limited to around 240 degrees of head movement. More than that should be blocked, so my Robloxian doesn’t get its neck snapped. I can’t find anything to help with my issue so I just posted it here.

The last few seconds of the video show my issue.

Shown game: https://www.roblox.com/games/7418604997/WW2-Stalingrad-Siberian-Front

Help would be appreciated! :grin:

2 Likes

are you using the default camera system? I know its super easy to implement a lock like that with a custom system.

I am currently using the default camera. Its not locked to any part.


The brick is the character’s head (visualised, not actual head.) and the invisible part is the spawn point.

This is the startercharacter used if that helps any more.

You could probably calculate the relative angle compared to the HumanoidRootPart. If said value is above your restriction, snap it back to your max rotation.

This might require .RenderStepped(), I don’t know how resource intensive this is.

There is no HumanoidRootPart…

That’s interesting.
You could still use the torso in that case, it will be “more” relevant anyways, since the neck is connected to the torso rather than the HumanoidRootPart.

@ifkpop is correct, you could calculate the Dot Product from a certain “forward facing” vector, calculated by a HumanoidRootPart, Torso, or even just a new part where the player’s head would be.

Based on this you can find the angle between the Camera’s LookVector and the part’s LookVector. When you do this you can then write a simple script to get the CFrame of the limited thing

(check the angle on RenderStepped since that is after the camera normally updates)

You can cap the vector then, (You might be able to get it by lerping directional CFrames by an alpha calculated by (TargetAngle / Dotproduct) )

4 Likes

Could you provide a basic code example of this, I am still trying to warp my head around it, and there is a few variables that are undefined in your explanation (a great explanation), eg you say “to get the CFrame of the limited thing”, I am not sure what thing is, and how to actually limit that camera (and how to calculate the cap etc)

3 Likes

Check the orientation of the Torso/Head maybe.

late reply but how does one do that cause I have found no dev forum post about it and the ones I posted didn’t get seen. please help.
Edit: And how did he even do that?