The camera system in GameCrom allows the camera to automatically follow
the player in order to keep them visible on screen during gameplay.
This behavior is controlled through the cameraFollow property, along with
several parameters that define how and when the camera moves.
true, the camera will follow the player.
"both": follows both X and Y (default value)."x": follows only horizontally."y": follows only vertically.
- If cameraFollow is set to false, the camera remains fixed.
- If cameraFollow is set to true, the camera will automatically move
to keep the player within the visible area, respecting the defined margin and smoothing.
Using the cameraFollowAxis property, you can decide on which axes
the camera should follow the player.
The axis that is not followed will remain fixed, even if the player moves in that direction.
By default, the camera system automatically follows any object of type
player, top_down_player, flying_player, or
point_click_player.
If you are using a player created through a custom script, you can manually tell the camera which object it should follow. To do this, add the following line in the Start event of the object script:
function Start(obj) {
cameraFollowTarget = obj;
}
This assigns the current object as the camera target.
Important: there must be no object of type
player in the scene, as the engineβs automatic system
has priority and will override this manual assignment.
{
"cameraFollow": true,
"cameraFollowAxis": "both",
"cameraSmooth": 0,
"cameraMargin": 50
}
π The camera will follow the player instantly when crossing the 50-pixel margin.
{
"cameraFollow": true,
"cameraFollowAxis": "both",
"cameraSmooth": 5,
"cameraMargin": 80
}
π The camera will move smoothly toward the player, keeping an 80-pixel margin.
{
"cameraFollow": true,
"cameraFollowAxis": "x",
"cameraSmooth": 4,
"cameraMargin": 60
}
π The camera will follow the player only horizontally, keeping the vertical position fixed.
{
"cameraFollow": true,
"cameraFollowAxis": "y",
"cameraSmooth": 6,
"cameraMargin": 40
}
π The camera will follow the player only vertically.
cameraSmooth = 0 results in a hard camera with no interpolation.cameraSmooth values create slower, smoother movement.cameraMargin prevents constant micro-adjustments and jitter.cameraFollowAxis allows classic camera behaviors without extra scripts.cameraFollowTarget can point to any game object,
as long as there is no active player in the scene.