Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with adjusting Camera Angles?

function camera()
	local target = workspace.MapHolder.Map:WaitForChild("Camera")
	currentCamera.CameraType = Enum.CameraType.Scriptable
	currentCamera.CameraSubject = target
	timeBox.Visible = false
    currentCamera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(90, 0, 0) * CFrame.new(0, 10, 0)
	wait(5)
	currentCamera.CameraSubject = player.Character.Humanoid
	currentCamera.CameraType = "Custom"
	timeBox.Visible = true
end

I currently have this script, which angles to camera to a selected part. What I am trying to figure out is how to get the Camera to angle down, so it is looking down on the part, like a birds eye view. I have tried editing the CFrame.Angles() numbers, but I can't seem to find the right combination.

1 answer

✓ Accepted answer

Try changing the portion where you set the camera CFrame to this:

local cameraOffset = Vector3.new(0,10,0)
camera.CFrame = CFrame.new(target.Position + cameraOffset, target.Position)

The way this works is a simple CFrame constructor, which does exactly what you want. If you create a CFrame with 2 Vector3s as arguments, it will create a CFrame at the position of the first one, pointing at the second, which is exactly what you want. FYI, CameraOffset is, as you might guess, the camera offset from your target part, which is nice because you can position the camera very easily.

EDIT: The full code, which aims at the target, then after 5 seconds switches to the player torso, which is I gather the point of the code.

function camera()
    local target = workspace.MapHolder.Map:WaitForChild("Camera")
    currentCamera.CameraType = Enum.CameraType.Scriptable
    currentCamera.CFrame = CFrame.new(target.Position + cameraOffset, target.Position)
	timeBox.Visible = false
    wait(5)
	currentCamera.CFrame = CFrame.new(target.Position + cameraOffset, player.Character.HumanoidRootPart.Position)
	timeBox.Visible = true
end

3 comments

0

It just points the camera up at the sky

0

Try the code in the edit. If that doesn't work, it may be some strange positioning of your target, or the :waitForChild may be preventing the code from ever running. You are trying to wait until the camera is a child of the map, correct?

0

Ok it works. Only problem was after the 5 seconds, the camera doesn't go back to the player, but I got it working fully now

This discussion is preserved as it was. New answers, comments, and votes are closed.