Make your battles take place in a different scene and return to your previous position after the battle using Battle Start and Battle End Events.
This tutorial focuses on the basics of changing to a battle scene and returning to the previous scene after battle. Feel free to add fancy animations, camera changes and messages (like Fight!) to the events.
The battle start event
In the Battle Start Event we need to remember the current position and scene of the player before loading the battle scene.
Event Settings
- Block Player Control
Enable this setting. - Block Camera Control
Enable this setting.
Store Music
Add > Animation + Audio > Music > Store Music
This step remembers the currently playing music and position of the track. No additional settings needed.
Change Music
Add > Animation + Audio > Music > Change Music
This step plays the battle theme.
- Play Type
Select Play.
You can also fade in or fade to the new music. - Music Clip
Select Battle Theme or whatever music you want to use.
Store Scene
Add > Game > Scene > Store Scene
This step remembers the current position of the player and which scene he is in. No additional settings needed.
Load Scene
Add > Game > Scene > Load Scene
This step loads fades out the screen and loads the new scene – we wont fade back in right now, first we’ll spawn the combatants. If the load scene step is used in battle start events, it will place the Battle object at the target position (a Spawn Point in our case).
- Target Scene
Set to 4 Battle Arena.
This scene comes with the tutorial resources – it’s a plain plane. - Target Type
Select Spawn ID.
We’re using a spawn point to place the battle. - Spawn ID
Set to 0. - Fade Out
Enable this setting. - Time (s)
Set to 0.5. - Interpolation
Select Linear. - Fade Alpha, Red, Green, Blue
Enable these settings. - Start Color
Select black without alpha (R=0, G=0, B=0, A=0). - End Color
Select black with full alpha (R=0, G=0, B=0, A=1). - Fade In
Disable this setting.
Spawn Combatants
Add > Battle > Combatant > Spawn Combatants
This step spawns our combatants at their battle spots.
- Spawn All
Enable this setting.
Fade Screen
Add > UI > Fade Screen
This step will fade the screen back in.
- Wait
Enable this setting. - Time (s)
Set to 0.5. - Interpolation
Select Linear. - Fade Alpha, Red, Green, Blue
Enable these settings. - Start Color
Select black with full alpha (R=0, G=0, B=0, A=1). - End Color
Select black without alpha (R=0, G=0, B=0, A=0).
And that’s it for the battle start event – click on Save Event and save it as, e.g. teleportStart.
Victory battle end event
The victory event is used when the player won the battle – it will load the previous scene after collecting the battle gains.
Event Settings
- Block Player Control
Enable this setting. - Block Camera Control
Enable this setting.
Change Music
Add > Animation + Audio > Music > Change Music
This step plays the victory theme.
- Play Type
Select Play. - Music Clip
Select Victory Theme or whatever music you want to use.
Collect Battle Gains
Add > Battle > Gains > Collect Battle Gains
This step shows a dialogue with what the player gained from the battle (experience, items).
- Show Gains
Enable this setting. - Wait
Enable this setting.
The event continues after the player closed the dialogue.
Change Music
Add > Animation + Audio > Music > Change Music
Now it’s time to play the previously stored music.
- Play Type
Select Fade To. - Play Stored Music
Enable this setting. - Fade Time (s)
Set to 1. - Interpolation
Select Linear.
Load Scene
Add > Game > Scene > Load Scene
Finally, we return to the stored position.
- Load Stored Scene
Enable this setting. - Fade Out
Enable this setting. - Time (s)
Set to 0.5. - Interpolation
Select Linear. - Fade Alpha, Red, Green, Blue
Enable these settings. - Start Color
Select black without alpha (R=0, G=0, B=0, A=0). - End Color
Select black with full alpha (R=0, G=0, B=0, A=1). - Fade In
Enable this setting. - Time (s)
Set to 0.5. - Interplation
Select Linear. - Fade Alpha, Red, Green, Blue
Enable these settings. - Start Color
Select black with full alpha (R=0, G=0, B=0, A=1). - End Color
Select black without alpha (R=0, G=0, B=0, A=0).
And that’s it for the victory event – click on Save Event and save it as, e.g. victoryTeleport.
Escape battle end event
The escape event is used when the player escaped from the battle – it will dismiss the battle gains and load the previous scene.
Event Settings
- Block Player Control
Enable this setting. - Block Camera Control
Enable this setting.
Clear Battle Gains
Add > Battle > Gains > Clear Battle Gains
This step removes all battle gains that have been collected during the battle … you escaped, you don’t deserve them! No further settings needed.
Change Music
Add > Animation + Audio > Music > Change Music
Now it’s time to play the previously stored music.
- Play Type
Select Fade To. - Play Stored Music
Enable this setting. - Fade Time (s)
Set to 1. - Interpolation
Select Linear.
Load Scene
Add > Game > Scene > Load Scene
Finally, we return to the stored position.
- Load Stored Scene
Enable this setting. - Fade Out
Enable this setting. - Time (s)
Set to 0.5. - Interpolation
Select Linear. - Fade Alpha, Red, Green, Blue
Enable these settings. - Start Color
Select black without alpha (R=0, G=0, B=0, A=0). - End Color
Select black with full alpha (R=0, G=0, B=0, A=1). - Fade In
Enable this setting. - Time (s)
Set to 0.5. - Interplation
Select Linear. - Fade Alpha, Red, Green, Blue
Enable these settings. - Start Color
Select black with full alpha (R=0, G=0, B=0, A=1). - End Color
Select black without alpha (R=0, G=0, B=0, A=0).
And that’s it for the escape event – click on Save Event and save it as, e.g. escapeTeleport.
Defeat battle end event
The defeat event is used when the player has been defeated in battle – usually you will call game over here. The Game Over Settings in Game > Game Settings define what to do on game over (e.g. load a game over scene and display a choice to load a game or start from a retry point).
In my case, calling game over will load a game over scene, so we don’t need to return to the previously remembered position.
Event Settings
- Block Player Control
Enable this setting. - Block Camera Control
Enable this setting.
Clear Battle Gains
Add > Battle > Gains > Clear Battle Gains
This step removes all battle gains that have been collected during the battle. You died, so you don’t get anything.
Change Music
Add > Animation + Audio > Music > Change Music
If you have a special music for game over, that’s where you want to start playing it – I’ll just stop the music.
- Play Type
Select Stop.
Game Over
Add > Game > Game > Game Over
This step calls game over – in case of the demo/game tutorial, a game over scene will be loaded and a choice is displayed. No further settings.
And that’s it for the defeat event – click on Save Event and save it as, e.g. defeat.
The battle scene
For our battle to successfully spawn in the battle scene, we need a Spawn Point with Spawn ID 0 in the scene. It’s recommended to disable Place On Ground and not add any Place On Ground components to the spawn point, otherwise this can result in the battle spots being misplaced when also using Place On Ground on them.
You can add a spawn point using the ORK Scene Wizard: Create Object > Spawn Point
- Spawn ID
Set to 0.
Since that’s the ID we used in the battle start event. - Place On Ground
Disable this setting.
And that’s it for the requirements of battle scene. Don’t forget to save your changes.
Adding the battle end/start events
The default battle start and battle end events are defined for each battle system type individually. E.g. for Turn Based battles, this is done in Battle System > Turn Based Battles. You can also use different battle start/end events for each Battle component individually.
To override the default battle events in your Battle component, change the following settings.
Battle Start Event
- Use Default
Disable this setting. - Start Event
Select teleportStart.
Battle End Events
- Use Default
Disable this setting. - Victory End Event
Select victoryTeleport. - Escape End Event
Select escapeTeleport. - Defeat End Event
Select defeat.
And that’s it!
Using different battle scenes
Since you’ll most likely want to change to different battle scenes depending on where the player currently is, you’ll either need to create a battle start event for each scene, or use a Game Variable to store the target scene.
To use a game variable, simply change the following settings in the Load Scene step of the battle start event.
- Is Variable
Enable this setting.
The Target Scene is now used as the variable key of a game variable. - Target Scene
Set to targetSceneName.
The name of the scene that will be loaded is taken from a game variable with the key targetSceneName.
For this to work, the variable targetSceneName has to be set to the name of a scene that will be loaded.
You can do this by creating a simple game event that sets the game variable – and use this event as an Autostart event (Event Interaction with start type Autostart) in your scene.