articles/customizing the camera|camera customization, you can manipulate the game camera to create specific player/character view systems, lock the camera to a world position, create unique camera effects, and more.
Camera has several built-in properties, including:
||The point in 3D space where the camera is looking. When pointing the camera in a specific direction, you should update this property because certain visuals will be more detailed depending on how close they are to the focus point.|
||The extent of the observable game world that can be seen on screen, measured between 1–120 degrees in the vertical direction (default is 70).|
Scripting the Camera
Inside scripts, the game camera can be accessed with the
StarterPack. Placing any of the following scripts elsewhere will not allow the code to properly take control of the camera.
A basic over-the-shoulder camera, commonly found in third-person shooter games, can be achieved with the following script. This camera stays locked behind the character’s back and players use the mouse to turn (not directional input).
-2, 2, 8) or pull the camera further away from the player (
2, 2, 15).
A simple scope in/out camera system can be implemented using the following script. This example uses the middle mouse button to zoom in and out, and the ability of
ContextActionService to create a virtual zoom button on mobile devices.
TweenInfo.new()on line 9 and the scope zoom power can be adjusted with the
FieldOfViewvalue on line 60 (values between 10 and 20 work best).
Rotate Around Object
To rotate the camera fully or partially around a part, experiment with the following script which features adjustable camera offset, rotation time, repetition count, easing styles, and more.
cameraOffsetvector values of
0, 30, 12, setting
truewill make the camera tilt downward to look directly at the object.