The Camera

by Jon (Updated on 2015-10-20)


  • Introduction
  • Scrolling
  • Example: Making the Camera Follow the Player
  • Moving the Camera
  • Off Screen Actors Become Inactive


In this article, we introduce the concept of the camera and describe how you can make games scroll using the camera.


Although some games exist entirely on a single screen, many extend beyond that. For example, think about a game similar to Super Mario Bros. Levels extend beyond a single screen.

In games like these, when the player walks to the right, the game “scrolls” to the right.

How does this “scrolling” work? In simple terms, scrolling is the act of changing what part of the scene is visible.

One can draw a connection to something we’re familiar with - peering through the viewfinder (or screen) of a camera to compose a photograph.

The “camera” in our engine is the exact same concept - it’s the “thing” that controls what part of the scene is visible.

Note: In fact, the “camera” is an actor! It’s an invisible, non-physical actor, but like any kind of actor, it has a position and it can be moved around.

Example: Making the Camera Follow the Player

In many games, the camera follows the player, so that the player is always on screen.

This turns out to be trivial to accomplish since we have a “camera follow player” block as well as a pre-defined Behavior that you can attach to any scene that does the same thing.

Moving the Camera

The camera can be moved in 2 different ways, both which involve these blocks (under Scene > View > Camera).

Camera Blocks

Method 1: Set the Position

Move the camera to a specific (x,y) position inside the scene.

Method 2: Move to Actor

This will set the camera’s position to the center point of the Actor.

Note: One question you may have is: what if I make the camera go outside the scene’s boundaries? It turns out that the camera is locked to those boundaries and won’t head beyond them.

Off Screen Actors Become Inactive

Something you may notice is that actors that are off screen stop working, as if they froze in time. We do this to preserve performance.

Nevertheless, there are cases where you want an actor to be active regardless of whether it’s on or off screen.

To make an actor always active, use the following block (under Actor > Properties > Misc).


  • Scrolling is controlled by the camera.
  • The camera is a special kind of actor. It has a position and can be moved around.
  • Off screen actors become inactive. Use the “always simulate” block to override this.

Challenge 1: Auto-Scrolling

In some platformers, levels can auto-scroll. The player has no control over the camera.

How do we accomplish this effect given that you only have control over setting the camera’s position?

One approach is to make a dummy actor that controls the camera (by having the camera continually follow this actor).

By controlling this dummy actor, you gain complete control over the camera and can do more with it, such as panning it towards a destination over a time period.

Your challenge is this: Create a game that implements auto-scrolling.

Once you’ve got a simple auto-scrolling behavior completed, extend it so that once it reaches its first destination, begin auto-scrolling to the next one. Generalize this to work with an arbitrary number of destination points.

After that, figure out a way to prevent the player from exiting from the left/right sides of the screen. If you play any Mario game, you’ll notice that there’s an invisible wall that pushes you along should you try to exit the sides of the screen.

Challenge 2: Grid-Based Camera

Retro games have seen a resurgence in the past few years. To complete the retro feel of these games, some developers go to great lengths to preserve the precise, “8-bit” feel of these games.

Your task is this: create a retro-feeling camera that locks to the scene’s grid.

Instead of smooth, continuous motion, the camera only assumes positions that are multiples of the tile size. Create a game with this kind of camera motion.

Print Article Edit Article How to Edit an Article
Disclaimer: Use comments to provide feedback and point out issues with the article (typo, wrong info, etc.). If you're seeking help for your game, please ask a question on the forums. Thanks!


No where in here does it say where the position of the camera is bound. Is it like actors? where there position is based on the top left edge?
1 11 months, 3 weeks ago
Let's say on a 640x400 screen i wanted to set the actor to always be at x=6 and y=6 since my view screen will be on the left which is 11x11 tiles. He needs to stay in the middle of that but have the rest of the world scroll as he walks. Stats and other info will be on the right which will hide anything until it comes into view in the view screen. How would i accomplish this? I have it already following the actor in the center of the screen. I just need to set it to fit in the center of the GUI view port.
-1 2 years, 3 months ago
How do I zoom the camera in more?? Like, to make the viewing window smaller??
2 2 years, 4 months ago
hi guys i got a problem with the camera and need help!
i got 2 scenes one is the world the other is battle
Lets say that i got 2 points in World scene A and B,
A is where the player is when the game starts
B is where the player picks a fight
Camera follows player from A to B and it switch scene to battle scene but when i return to World scene the player loads at point B where the camera loads at Point A and the game freezes.
and i want both player and camera to load exactly where they left off from last world scene coordinates

if anyone know how to fix this problem please help.

2 3 years, 1 week ago
Excellent tutorial!
1 3 years, 2 months ago
cheesynoddle: I'm not sure, but a possible workaround would be to rotate every game object (therefore the whole game world) around a set point. Not the most elegant solution, I must admit.
0 3 years, 4 months ago
Is there any way to rotate the camera? I'm interested in tilting it, or turning it upside down.
2 3 years, 5 months ago
It should be noted that "Move Camera to x, y" means the CENTER of the camera will focus at x, y. Not the Top Left corner of the camera.
1 3 years, 5 months ago
You need to attach the Camera Follow to the player character actor
1 3 years, 6 months ago
i downloaded "camera follow player" from stencyl forge and i also tried "smooth camera" and none of these work . it usually ends up not following the character
0 3 years, 7 months ago

Sign In to Comment