CameraControllingEntity
Last updated
Last updated
The CameraControllingEntity provides a standardized way to control camera position in games which contain a moving character or which use Tiled for maps.
This page discusses working with the CameraControllingEntity in the FRB Editor. For information about how to work with it in code, see the CameraControllingEntity API Documentation.
If your game was created with the wizard, then your GameScreen has an instance called CameraControllingEntityInstance.
This instance targets the PlayerList (averages the position of all Players in the PlayerList) and will restrict the visible area to the Map object.
The Extra Map Padding property adds a number of pixels of offset between the edge of the actual map and the desired visible edge. A positive value adds padding, effective shrinking the available area that the camera can view. A negative value allows the camera to move outside of the map. Note that the property on the CameraControllingEntity is called Map since this is the most common type of object used to control bounds, but it doesn't have to be a map.
You can manually add a new instance to your game if you do not already have an instance in the GameScreen. Keep in mind this may have already been done for you if your game was created using the new project Wizard. To add a CameraControllingEntity to a game that has not used the Wizard:
Select your GameScreen
Select the Quick Actions tab
Click the Add Object to GameScreen button
Select the Camera Controlling Entity option
Click OK
Once you have created the instance, you can assign it the object to follow and the map to use as the visible bounds. To set which object the camera will follow:
Select the newly-created CameraControllingEntityInstance
Click the Variables tab
Select which object to follow in the Targets list. Notice that you can select entire lists of objects too, which will result in the CameraControllingEntity using the center position for all objects.
Similarly, the Map object can be set to control the visible bounds of the camera using the Map dropdown.
At runtime the Camera will automatically follow the target with no additional code required.