A game usually consists of multiple scenes – the easiest way to connect them to a bigger game world is using Spawn Points and Scene Changers.
A Spawn Point defines a position in a scene and is used by Scene Changers and Game Events. The spawn point is found by it’s unique Spawn ID. You can also use the spawn points rotation and scale when spawning the player.
Use the ORK Scene Wizard to add a spawn point to a scene: Create Object > Spawn Point. The newly created game object will have a Spawn Point attached and automatically receive a new Spawn ID. Now place the spawn point where you want the player to spawn in the scene, if it’s ID is used.
The Spawn ID must be unique in the scene, if two spawn points have the same ID, the first spawn point that’s found will be used. Each scene has it’s own spawn IDs, having the same spawn ID in multiple scenes is possible.
You can edit the following settings in the spawn point’s inspector.
Get New Spawn ID
Get’s the first free Spawn ID.
Reset All IDs
All spawn points will receive a new Spawn ID.
The ID of this spawn point.
Use Y Rotation
The Y-axis rotation of the spawn point’s game object will be used when spawning the player. The player’s Y-axis rotation will be set to the spawn point’s.
The scale (localScale) of the spawn point’s game object will be used when spawning the player. The player’s scale will be set to the spawn point’s scale.
Place On Ground
The spawn point will be placed on the ground below using a raycast. Define the Distance and Layer Mask used for the raycast.
A Scene Changer is an easy way to change your scene in a running game. It’ll fade the screen, change to the new scene and spawn the player there.
Use the ORK Scene Wizard to add a scene changer to a scene: Create Object > Scene Changer. The newly created game object will have a Scene Changer and a Sphere Collider attached and automatically be set up for Trigger Enter event start. The scene will be changed when the player walks into the scene changer, but you can also use other event start types, like Interact (when the player needs to press a key, e.g. for doors).
The target of a scene changer is defined by the Target Scene settings. If multiple target scenes are added, one is selected randomly.
Add Target Scene
Adds a new target scene to the scene changer.
The value of Game Variable (string) is used as the name of the scene.
Target Scene is used as name of the game variable.
The name of the scene that will be loaded.
If Is Variable is enabled, the name of a Game Variable (string) containing the name of the new scene.
Where to spawn the player in the next scene can be defined by multiple things:
- Spawn ID
A Spawn Point is used. Define the Spawn ID of the spawn point.
Define the Position (X, Y, Z) and Y-Rotation used to spawn the player.
- Scene Position
The stored Scene Position is used. You can store a position for each scene using the Event System.
This can be used to e.g. save the last position of the player in a scene before teleporting away and return there later.
The value of a Game Variable (Vector3) is used.
Define how the scene change will be started. Select the Start Type and the Orientation of the player to the game object of the scene changer. The start settings are the same for all scene events in ORK Framework and will be covered in detail in another how-to.
The selected audio clip will be played when changing the scene.
Remove Scene Data
You can remove stored scene data when changing the scene. Either from None, the Current (old) scene, the Next (new) scene or from Both. When you select to remove scene data, you can additionally select which data you want to remove (e.g. dropped and collected items or finished battles).
Screen Fade Settings
Scene changers can fade the screen before and after changing the scene. The settings for fading out (before changing the scene) and fading in (after changing the scene) are the same, but keep in mind that you need to invert the start/end colors when fading colors (e.g. for the color’s alpha value: fading out from 0 to 255, fading in from 255 to 0).
The fade will be performed if enabled.
The time in seconds used to fade.
Select the interpolation function you want to use (e.g. linear).
The alpha, red, green or blue values of the color will be faded if they’re enabled.
The current color of the screen fader will be used as start color.
E.g. if the screen has been faded by an event to a different color, this color will be used as the start.
The start color when fading.
The end color the screen will fade to.
Additionally, scene changers can be dependent on Variable Conditions and set Game Variables after changing the scene.
Learn more about game variables and how to change or check them in this how-to.