CameraProfiler
The Camera Profiler package represents a singleton that you can use to better leverage the Camera system wihin the Roblox Environment. This camera system
works through setting Workspace.CurrentCamera
to the camera the developer wants to see.
Example of how you would create a profile
local BlimpCameraProfile = CameraProfiler:Profile({
Name = "BlimpCamera"
})
function BlimpCameraProfile.Construct(self: BlimpCameraProfile)
print("Setup blimp camera variables!")
end
function BlimpCameraProfile.Start(self: BlimpCameraProfile)
print("Camera started, do things!")
end
function BlimpCameraProfile.Stop(self: BlimpCameraProfile)
print("Camera stopped, clean things up!")
end
export type BlimpCameraProfile = typeof(BlimpCameraProfile)
return BlimpCameraProfile
Example of how you would use the newly created profile
CameraProfiler:Set("BlimpCamera")
Example of how you would integrate a Profile with the default Camera Roblox creates.
local DefaultCameraProfile = CameraProfiler:Profile({
Name = "DefaultCamera"
}, workspace.CurrentCamera)
Properties
CameraStarted
CameraProfiler.CameraStarted :: Signal<Name: string>
This signal is fired after a camera has started.
CameraStopped
CameraProfiler.CameraStopped :: Signal<Name: string>
This signal is fired after a camera has stopped.
Methods
Profile
CameraProfiler:Profile(
profilePrototype
{ Name: string, Construct: ((self: Profile) -> ())?, Start: ((self: Profile) -> ())?, Stop: ((self: Profile) -> ())?, },cameraInstance
Camera? ) -> Profile
Call this function to register your camera profile, a camera profile is a Roblox table that wraps around a camera instance, the goal of this table is to make interacting and handling with cameras easier within the engine.
Example:
local CameraProfile = CameraProfiler:Profile({
Name = "CameraProfile"
})
function CameraProfile.Construct(self: CameraProfile)
...
end
export type CameraProfile = typeof(CameraProfile)
return CameraProfile
Set
CameraProfiler:Set(
profileName
string (opens in a new tab) ) -> ()
Will set what the active camera should be, sideeffects of calling this method are:
- Will call the
Stop
lifecycle on the current camera instance. - Will set the
Workspace.CurrentCamera
property to the updated camera instance. - Will call the
Start
lifecycleo n the new camera instance.
Get
CameraProfiler:Get() -> string? (opens in a new tab)
Will return the name of the currently active camera, or nil.