Roblox has many features that make users fun and comfortable being in this gaming platform. There are a lot of things that can be explored by people during they spend their time in Roblox. So, there is no reasons why we just spend for a short time in Roblox. One of those features is the ability to create game in Roblox Studio. In making game, we know that there are a lot of things that must be considered. And now, we are going to talk about Camera especially CurrentCamera.
Camera object sets a view of the 3D environment. In an example of the game, every client has its own Camera object which is associated with it. Camera objects exist only upon the client of the viewer and it resides in that user’s local Workspace. Therefore, it cannot be edited directly from the server. On this most latest versions of the game, the only way to access a the Camera object of a client is through a LocalScript which runs on that client. For your information, every specific Camera object of a client is able to be accessed via the Current Camera property of its local Workspace. It assumes your code is running in that specific client.
The state of Camera is defined as described below.
- The CFrame property indicates the orientation and position of the camera.
- The Focus property indicates the point the camera is looking at.
- The Camera Type property indicates the action that the game engine should perform on the Camera every frame.
- The FieldOfView property, a number, indicates the angle that the user can view the sides of the Camera.
- An internal roll amount that is able to be set by utilizing the SetRoll method.
How about CurrentCamera? It is a property of Workspace and it is a link to an object. It means that the object is links to is a Camera. It is the camera belonging to the local player. The word ‘local player’ brings the fact that only LocalScripts can get access to it. However, if you want to edit the CurrentCamera is simple and it can enhance your game a lot. So, how to add objects to it? You can add objects to the current camera easily. When an object is parented to CurrentCamera, you have to know that only the local player can view and interact with it. It can be useful for things like gates that are only visible by certain players. This method is not recommended anymore because parenting objects to Workspace through LocalScrips has the similar effect. Here, there is an example usage which makes a part when a TextButton is hit. This script is ran in a LocalScript inside the TextButton.
script. Parent. MouseButton1Click: Connect (function()
local part = Instance. new (“Part”)
part. Parent = game. Workspace. CurrentCamera end)
Currently, this part only acts physics upon the Local player. It is crucial to note that objects placed in the Camera before the game begin will be destroyed. All objects which are put into the CurrentCamera have to be put in from a LocalScript after the game is ran.