When you’re playing your game, you may notice that the camera follows the player and is always centered on the player unless you’ve reached the edge or corner of the map.
Sometimes, you may want to focus the camera on a different object, or an arbitrary position on the map. For cut-scenes where the player is not involved, for example, you would typically have to set the player’s graphic to transparent and then move the player to the cut-scene’s location. After the cut-scene is over, you would then move the player back to where they were.
This is not a difficult task, but it is not really something that you have to do just to look at somewhere else on the map. One solution that would make your cut-scenes and overall eventing experience so much easier is the ability to control the game camera using the Camera Target script.
- Script: Camera Target
We can consider the game to initially only have one camera. Whatever you see on the screen is through the lens of that camera. Through scripts, you can potentially add more cameras, but for now there is only one, and it follows the party leader. The leader is said to be the “target” of the camera.
When you move your party around the map, the camera follows its target by sliding the map. Once you reach the edge or corner of the map where it is no longer possible to continue sliding, the camera will stay in that position until you move elsewhere.
How the script works
The Camera Target script provides a single function: changing the target of the camera to another character on the screen. Valid characters that you can choose are
- The leader of the party
- A party follower
- An event on the map
The target is changed via script calls, which can be used using the script call command, or a move route command if you require the camera target to change during a move route.
You can designate an event as the target of the camera. This will center the camera on the event, regardless how you move the party leader.
The event can be a visible event that you want to follow, such as an NPC that moves across the screen. You don’t necessarily want to have to figure out how to scroll the map while the event moves, or move an invisible player along with the event to accurately follow the event’s movements.
The event can also be an invisible event, whose purpose is to simply move the camera around the map without having to scroll the map or change the player’s position.
This invisible event can remain at a particular position so that the camera is fixed to a particular position, or the event can move around to simulate map scrolling independent of any other characters on the map.
By combining events and camera targeting, you can achieve a variety of effects in your cut-scenes without having to figure out how to coordinate the player or scroll the map so that the camera will correctly do what you want it to do.
Spread the Word
If you liked the post and feel that others could benefit from it, consider tweeting it or sharing it on whichever social media channels that you use. You can also follow @HimeWorks to get the latest updates or suggest topics that you would like to read about.