I am trying to achieve an end goal of setting the cameraβs position through a LocalScript. I am making a loading screen that displays a room of a building.
How would I implement this?
I am trying to achieve an end goal of setting the cameraβs position through a LocalScript. I am making a loading screen that displays a room of a building.
How would I implement this?
Youβre gonna have to learn how to use the Camera servlce. Itβs not hard. You just need to use the Camera service and set the Camera/CameraSubject property.
But, if youβre looking to set the camera positon, youβre gonna have to use the Camera/CameraType property.
I have figured out a way to do this, which is works. However, I need to ensure the camera is facing a certain direction. How would I do this?
local Player = game:GetService("Players").LocalPlayer
local Screen_Interfaces = {
["Loading"] = Player.PlayerGui:WaitForChild("MainUI").LoadingSystem
}
local Assets_Table = {
["Loading//Title"] = Screen_Interfaces.Loading.AssetsBar.Title,
["Loading//Description"] = Screen_Interfaces.Loading.AssetsBar.Description,
["Loading//Final"] = Screen_Interfaces.Loading.FinalTip,
["Loading//Camera"] = game:GetService("Workspace").CameraFolder.Loading
}
local Services = {
["Tween"] = game:GetService("TweenService"),
["Camera"] = game.Workspace.Camera
}
Services.Camera.CameraType = Enum.CameraType.Scriptable
if Services.Camera.CameraType == Enum.CameraType.Scriptable then
warn("Unexpected Error: Failed to set the camera type.")
else
Services.Camera.CameraType = Enum.CameraType.Scriptable
end
Services.Camera.CFrame = Assets_Table["Loading//Camera"].CFrame
Script ^
You can do this. You just need to use the Camera/CFrame property.
I have tried to do that, it doesnβt work. Can you provide a script?
No. β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
I think you should also add CurrentCamera.CameraSubject = --put the part you want it to be.
.
Make sure the part is definetly invisible. AND use CurrentCamera (game.Workspace.CurrentCamera
)
If you want it to face a certain direction, theres some things you can do:
Orientation.
What I like to do here is not use CameraSubject, but create a transparent part in the workspace and make it the subject I want the camera to look at.
So in the case of your script, it would look something like this:
Services.Camera.CFrame = CFrame.new(Vector3.new(Position you want your camera to be in), Vector3.new(Position of part you want your camera to look at))
(At least, this is what worked for me when I tweened my camera to a position and direction I wanted)
The values inside Vector3.new would be the CFrame position values you copy from your camera part and camera subject.