Difference between revisions of "Camera"
Line 6: | Line 6: | ||
To move the camera, first assign the camera to follow an [[Actor]]. The most common pattern is to do this inside a [[Rule]] when the actor is created: '''When this is created: Follow this with the camera'''. | To move the camera, first assign the camera to follow an [[Actor]]. The most common pattern is to do this inside a [[Rule]] when the actor is created: '''When this is created: Follow this with the camera'''. | ||
Next, move the actor, either by assigning the actor some controls, or by giving it a velocity. As the actor moves, the camera will move with it, and you'll see more of the world space. | Next, [[Motion|move]] the actor, either by assigning the actor some controls, or by giving it a velocity. As the actor moves, the camera will move with it, and you'll see more of the world space. | ||
The camera can only follow one actor at a time. | The camera can only follow one actor at a time. | ||
Line 18: | Line 18: | ||
To position an actor relative to the camera, edit its blueprint in the [[Inspector]], navigate to the '''General''' tab, and toggle '''Relative to camera'''. | To position an actor relative to the camera, edit its blueprint in the [[Inspector]], navigate to the '''General''' tab, and toggle '''Relative to camera'''. | ||
Relative-to-camera actors will not collide with card space actors. You can think of them as existing in a separate layer. | Relative-to-camera actors will not [[Collision|collide]] with card space actors. You can think of them as existing in a separate layer. |
Revision as of 20:56, 13 May 2022
The Camera represents the position in a Card's space which is visible to the player.
Moving through large worlds
Moving the camera is a mechanism for showing more of the world than will fit on screen at once. All Castle cards have a 10x14 viewport which is centered on the camera, which sits at (0, 0) by default. If a card needs more space that doesn't fit within that viewport, the solution is to move the camera.
To move the camera, first assign the camera to follow an Actor. The most common pattern is to do this inside a Rule when the actor is created: When this is created: Follow this with the camera.
Next, move the actor, either by assigning the actor some controls, or by giving it a velocity. As the actor moves, the camera will move with it, and you'll see more of the world space.
The camera can only follow one actor at a time.
Detecting when something is inside or outside the viewport
It can be useful to know when something enters or leaves the visible space in the card. You can detect this with the Triggers When this enters the camera viewport and When this exits the camera viewport. There is also a Condition for If this is in the camera viewport.
Positioning an actor relative to the camera
By default, all actors are positioned in card space. However, it can be useful to pin something to a particular part of the screen, even when moving through the world. For example, when building a health bar or displaying the score of a game, you might want that information to remain at the top of the screen. (Sometimes these elements are referred to as a HUD / Heads Up Display.)
To position an actor relative to the camera, edit its blueprint in the Inspector, navigate to the General tab, and toggle Relative to camera.
Relative-to-camera actors will not collide with card space actors. You can think of them as existing in a separate layer.