How do i rotate a part that's looking down without it looking up

the question is formatted weird, but basically i have 3 cameras for my menu that do 360 rotations. i want them to look slightly down (like this)
image
without them looking up because i’m rotating them. it’s probably an easy solution lol

task.spawn(function()
	while task.wait() do
		cams.Cam1.CFrame *= CFrame.Angles(0, math.rad(0.5), 0)
	end
end)
3 Likes

You may just need to set the Transform of the object to world. I don’t know how to script this off the top of my head, but you can do CTRL L (windows) or CMD L (mac) to change the transformation to world.

1 Like

i already did that, and it still looks up

1 Like

I will get on Studio in a little bit and see if I can solve it. I would check if you can change the Transform Coordinates of an object through a script if you can.

2 Likes

So basically you want it to rotate in world space not local space?

Local space is relative to itself, World space is relative to the world axis

If you could show a video of how it rotating might be able to help you better

1 Like

1 Like

Try

task.spawn(function()
	while task.wait() do
      local x,y,z = workspace.Camera.CFrame:ToOrientation()
	  cam.Cam1.CFrame = CFrame.new(cam.Cam1.CFrame.Position) * CFrame.Angles(x, math.rad(0.5), z)
	end
end)
1 Like

changed it to this because it was flipping upside down and it’s not rotating at all now?

task.spawn(function()
	while task.wait() do
		local x,y,z = workspace.Camera.CFrame:ToOrientation()
		cams.Cam1.CFrame = CFrame.new(cams.Cam1.CFrame.Position) * CFrame.Angles(x, y, math.rad(0.5))
	end
end)

Try

local rotations = 0
task.spawn(function()
	while task.wait() do
		local x,y,z = workspace.Camera.CFrame:ToOrientation()
        rotations += 1 % 360
		cams.Cam1.CFrame = CFrame.new(cams.Cam1.CFrame.Position) * CFrame.Angles(x, y, math.rad(rotations))
	end
end)
1 Like

it wasn’t rotating correctly like i wanted to and i switched it to X and i became a washing machine

Try
@bloodbonniekingnoob1

local rotationAmount = 1
task.spawn(function()
	while task.wait() do
      cams.Cam1.CFrame = CFrame.new(cams.Cam1.CFrame.Position, cams.Cam1.CFrame.Position + cams.Cam1.CFrame.LookVector * 5) * CFrame.Angles(0, math.rad(rotationAmount), 0)
	end
end)
1 Like
task.spawn(function()
    while task.wait() do
        local currentRotation = cams.Cam1.CFrame:ToEulerAnglesXYZ() -- Get the current rotation
        local newY = currentRotation.Y + math.rad(0.5) -- Add rotation around the Y axis
        cams.Cam1.CFrame *= CFrame.Angles(currentRotation.X, newY, currentRotation.Z) -- Apply the new rotation while keeping the current rotation on X and Z axes
    end
end)

@bloodbonniekingnoob1
If it worked please mark my most recent answer as a solution, so people know its solved.

You might need to store the camera’s original CFrame in a variable before rotating it, like so:

local cam1CFrame = cams.Cam1.CFrame

task.spawn(function()
	while true do
		cams.Cam1.CFrame = cam1CFrame * CFrame.Angles(0, math.rad(0.5), 0)
		task.wait()
	end
end)

@bloodbonniekingnoob1 It could also be that you’ll need to update the camera’s Focus property:

local cam1CFrame = cams.Cam1.CFrame

task.spawn(function()
	while true do
		cams.Cam1.CFrame = cam1CFrame * CFrame.Angles(0, math.rad(0.5), 0)
		cams.Cam1.Focus = cams.Cam1.CFrame
		task.wait()
	end
end)

@astraIboy their solution is getting close, im making a few changes based on my assumption of your implementation;
I will be assuming you want to rotate a part/camera/cframe around the Y axis whilst remaining facing down at a constant angle.
I will be assuming ur doing this manipulation on the client side and thus will be using RenderStepped.

-- Code should be ran in a LocalScript
local RunService = game:GetService("RunService")
local Part = workspace:WaitForChild("Part")

local ROT_SPEED = math.rad(45) --Rotation speed in radians per second (converted from degrees for your convenience)
local DOWN_ANGLE = math.rad(30) -- Constant angle at which the part is facing downwards
local TAU = 2 * math.pi

local rot = 0

RunService.RenderStepped:Connect(function(dt)
	rot += ROT_SPEED * dt
	rot = rot % TAU
	Part.CFrame = CFrame.new(Part.Position) * CFrame.Angles(0, rot, DOWN_ANGLE)
end)

Visual for result

3 Likes

it’s doing this now?

local cams = workspace.Technical.Menu
local module = require(workspace.Technical.CameraBindModule)
local speed = math.rad(45)
local angle = math.rad(30)
local TAU = 2 * math.pi
local rotation = 0
local rs = game:GetService("RunService")

rs.RenderStepped:Connect(function(dt)
	rotation += speed * dt
	rotation = rotation % TAU
	cams.Cam1.CFrame = CFrame.new(cams.Cam1.Position) * CFrame.Angles(0, rotation, angle)
end)

Sorry for the late reply, the streamable is no longer watchable so im not sure as to what the bug is, please verify that the CameraBindModule is being executed as expected tho seeing the other code should be correct.

1 Like

is it, since it only uses a render stepped event to constantly update the camera.

this is what i am referring to.

Ah! looking back at my initial footage of the rotating part, it seems like you are assuming the logical Front face of the part, whereas the one I was intending to use would be the Left face, you could either fix this by offsetting again within the camera module, OR the in my opinion more sensible approach of using RotationOrder

On a 2nd note I did not get RotationOrder to work myself as quickly as I would like, I tested manually doing the two manipulations in order and that worked.

Updated line of code would be;

cams.Cam1.CFrame = CFrame.new(cams.Cam1.Position) * CFrame.Angles(0, rot, 0) * CFrame.Angles(DOWN_ANGLE, 0, 0)

(I am again sorry for my late reply, I really do hope you were able to resolve it on your own, and if not I hope this resolves the last of your issues)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.