Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I detect degrees of rotation in my camera?

Asked by 6 years ago

I'm trying to find out how to find each degree of rotation a camera is looking at while turning left or right. I used a method where you start and 0,0 and you subtract that value with delta.x That way you get a 360* rotation. However, say my camera faces directly at a target and it's at 0,0. When I do a full rotation of my camera and land back on the target, I'm no longer on 0,0 but some other random number like -22, 0.

This script is how I detect the degrees of rotation.

TargetAngleX = 0,0 
TargetAngleY = 0,0 
Sensitivity = 0.1
Smoothness = 0.05

input.InputChanged:connect(function(inputObject)

    if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
        local delta = Vector2.new(inputObject.Delta.x/Sensitivity,inputObject.Delta.y/Sensitivity) * Smoothness

        local X = TargetAngleX - delta.y 
        TargetAngleX = (X >= 80 and 80) or (X <= -80 and -80) or X 
        TargetAngleY = (TargetAngleY - delta.x) %360 
        print(delta.x)
    end 

end)
0
Also if possible how can I get where the camera is facing in a vector2 value? laughablehaha 494 — 6y

Answer this question