Rotate Camera with tween while keeping position

  1. What do you want to achieve?
    all I want is to tween the orientation of the camera without tweening the position via CFrame

  2. What is the issue?
    The code i have does tween the camera’s rotation, however since I’m forced to use CFrame as the tween value it also keeps the camera stationary when the tween starts when i only want to rotate it but keeping its position on the character

  3. What solutions have you tried so far?
    pretty much a skim on devforum, and the wiki to see if it was possible to change the rotation of the camera without using the same statement i see everywhere:

Cam.CFrame *= CFrame.Angles(--values)

Here’s my line of code pretty much

tweenService:Create(cam, camInfo, {CFrame = cam.CFrame * CFrame.Angles(math.random(-1, 1), math.random(-1, 1), 0)}):Play()

I have no other ideas and I’m pretty much at loss as usual.

my camera stops following character when tween plays which is not ideal.

1 Like

this should be going from -180 to 180. Also, use math.rad.

CFrame.Angles(math.rad(math.random(-180, 180)), math.rad(math.random(-180, 180)), 0)

Trust me, I’m fully aware about radians and rotational values. The issue is that when the tween plays, while yes it rotates, but it also stays in place until the tween is done and then places the position back onto the character.

1 Like

Oh, well, you might want to be using a repeat instead.

local origx, x= math.random(-180, 180), x
local origy, y = math.random(-180, 180), y
local timer = 5 --seconds
local hasbeen = 0

    local took = task.wait()
    local xrad = x > origx/(took/timer) and math.rad(origx/(took/timer)) or math.rad(x)
    local yrad = y > origy/(took/timer) and math.rad(origy/(took/timer)) or math.rad(y)
    cam.CFrame = cam.CFrame * CFrame.Angles(xrad, yrad, 0)
    hasbeen += took
    x -= x > origx/(took/timer) and origx/(took/timer) or x
    y -= y > origy/(took/timer) and origy/(took/timer) or y
until hasbeen >= timer or x== 0 and y == 0

while i appreciate the snippet of code you’ve given me, I ended up just going with sleitnik’s EzCameraShake module, since doing the math myself would just be a whole other project and a headache that’s just not worth