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

Rotating camera to where the character is?

EDIT: To further explain, I have attempted to make a picture of what I want to do, this can be viewed here.

Hi all, I have the following script at the moment which gives a top-down view of my playing surface for my game.

game.StarterGui:SetCoreGuiEnabled("All",false)
game.StarterGui:SetCoreGuiEnabled("Chat",true)

repeat wait() until _G.Players
Players = _G.Players

function findPlayer(plr)
for i,v in pairs(Players) do
if v == plr then
return i
end
end
return false
end

local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local plrNum = (findPlayer(player) ~= false) and findPlayer(player) or nil
repeat wait() until camera and plrNum ~= nil

camera.Focus = game.Workspace["Playing Surface"]["Chair"..plrNum].Seat.CFrame
camera.CameraType = "Scriptable"
camera.CoordinateFrame = CFrame.new(game.Workspace["Playing Surface"].Table.Position + Vector3.new(0,15,0)) * CFrame.Angles(math.rad(-90),0,0)

It works, but I want it so that the camera is the same rotation of where the character is sitting around the table, so that the player's character is always near the bottom of the screen. Right now, the position of the player on the camera corresponds to the player number property.

P1 = Right of the screen.

P2 = Bottom of the screen (where I want all of the players' characters to be on their screen.)

P3 = Left of the screen.

P4 = Top of the screen.

Any help is appreciated, thanks.

2 comments

0

Just create an invisible Part with the correct CFrame, then set the camera's CFrame to that.

0

I've tried to simplify my problem by adding a picture, check my edit.

1 answer

Well, you can simply use setRoll(angle) method of the camera. It would look something like this:

camera:setRoll(-90+90*(playerNum-1))

If that doesn't rotate the camera properly, just play around with the numbers, but I think this should be alright.

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