I followed one of the Forum topics here about using RenderStepped for Camera Movement, the script works, however I have multiple camera position, how would I use it for more than 1 camera? I already did an if and else statement and it didn’t really worked or maybe I just did something wrong?
What is Cam1 and Cam2 variables? Objects in your workspace?
That scripts seems that binds the movement of mouse to slightly change the player’s camera rotation and its fixed to the Cam1.CFrame position.
But, when you want to include a “2nd camera” you mean that you want to stop using the Cam1 position and use only the Cam2 position to handle the pivot of the rotation? Like switching from one to another?
I think, depends on what exactly you mean by “at once”.
You can use multiple camera positions and shift the player’s cam to those different positions and make them able to rotate with the mouse movement. But, when you say “use the cameras at once” I kinda understand using all positions of all cameras at the same time. Which obviously makes no sense hehe.
Just create a function that handle which camera you want to “use” in your RenderStep. I mean a way you provide for the user to shift cameras to the next one or choose one in particular, depending on your goal and game mechanics.
I dont know whats the mechanics you are aiming for, maybe somekind of surveillance cameras system?
oh sorry for the confusion I only want to use 1 camera at a time per selection on UI’s since when I hover over my UI, I switch over a different screen, and its a bit bland without the camera moving at all.
-- List of all cams
local Cams = {
workspace:WaitForChild("Cam1"),
workspace:WaitForChild("Cam2"),
workspace:WaitForChild("Cam3"),
}
-- Variable holding the current cam to use
local CamToUse = false
-- Choosing a random cam from array
local function ChangeCam()
CamToUse = Cams[math.random(1,#Cams)]
end
RunService.RenderStepped:Connect(function()
local maxTilt = 10
CurrentCam.CFrame = CamToUse.CFrame * CFrame.Angles(
math.rad((((Mouse.Y - Mouse.ViewSizeY / 2) / Mouse.ViewSizeY)) * -maxTilt),
math.rad((((Mouse.X - Mouse.ViewSizeX / 2) / Mouse.ViewSizeX)) * -maxTilt),
0
)
end)
-- Call it when you want to choose a new random cam
ChangeCam()
Just instead of calling it random, call a specific entry of your table of cams CamToUse = Cams[1] -- this is using the first cam on the list
Mine was only an example of the implementation, you can call for any camera you desire, I was showing you that by having a variable that changes holding the camera reference, your RenderStep loop will follow that reference whenever you change it
That will return a variable to the ChangeCam to change to that camera to 1?
kinda like this one I did, do you think this will function?
local function ChangeCam(State)
CamToUse = MainMenuCameras[State]
end
ChangeCam(1) -- I have set this so whenever the ChangeCam gets called, it will
-- Send a Variable "1" to ChangeCam.