Open Dev Kit Documentation :: Demo - 3D Platformer
3D platformer game with moving platforms and enemies utilizingHow it Works
- Game Initialization
- Upon starting the game, the
Start function is triggered. This initializes theStartingMap Scene and the player's starting location via theScene Add function, which derives this data from thegSettings variable that can be accessed via theGame Settings menu in the main toolbar.
After some essentials are done initializing, theStart function calls theStart Game function which in turn then sets up other things like giving the player character a weapon, setting up their rotation, playing music and bringing up a menu with control instructions in the form of a message box. Because the 2nd message box displaying "START GAME" hasPause Script ticked, the remaining events succeeding it will not execute until the player interacts with the message box. Then the gameplay will begin. - Player Controls
- At the start of the game, the
Start function has aScene Add function with anInput Type parameter set toRegular Game , meaning when the specifiedScene gets added theRegular Game Keybind also becomes active.
The reason the player still cannot move however is because afterwards theStart Game function gets called which executes aMessage Box function with theCan Close parameter ticked (set to 1/true). TheMessage Box function also has aScene Add function with anInput Type parameter set toInterface , meaning when it gets executed, theInterface Keybind will exclusively become active.
When the player hits the "Enter" key to close the message boxes, theAccepted Event of theMessage Box Scene is triggered, which executes aScene Remove function that callsUpdate Active Inputs , a function which updates which inputs should be enabled based on current activeScenes . - Active Scenes
- The 3D Platformer demo has an
SceneAdd adds aScene to the current list of activeScenes and defines how theScene interacts (overlay or parallel), and even determines input behavior when theScene is active,- while
SceneRemove removes a specificScene from the active list, while also automatically shifting interaction focus to the next availableScene (useful for closing UI elements/menus and transitioning back to gameplay).
ActiveScene class, which is essentially a system to dynamically manage and switch between different UI and gameplay elements, or transitioning between different parts of the game without unloading other content. This is achieved using theSceneAdd andSceneRemove functions.
Creating a Max Heart Pickup
Follow these steps to add a new pickup actor to the demo that increases the player's max HP by 1:
- Create the New Item:
- Open
.Tools >Resources - Double-click the
Collectables Sprite Resource . - Copy the existing heart model and paste it over to a blank tile.
- Click on it to select it on the sequencer and set its
Color to preferably yellow. - Because the model by default is red, you also need to increase the color's magnitude component to a high enough value like
100 so that it overwrites it. Alternatively you can also import your own model if you wish.
- Open
- Set up the New Item:
- Open
.Tools >Globals / API - Since the heart pickup we're making functions very similar to the existing heart, we'll be using that as a base so copy+paste it and name it to something like
HeartMax . - After pasting it, change its graphic to the new heart by setting the
Default value of itsLayers property to{{Sprites/Characters/Collectables,2,{1,1,1,1},-1}} . This will grab the graphic from the 3rd tile of theCollectables Sprite Resource , which is the new golden heart. - Set up its functionality by editing the script of the
Collision Actor Started Event . - Add a
Change Max function before the existingChange Current function, and set it to increase the player character's max HP by one.Identifier =char.mStatistics.mHP Value =char.mStatistics.mHP.mMax + 1
- If you want the player's HP to also be replenished, keep the
Change Current function, but for itsValue usechar.mStatistics.mHP.mMax instead. The updated script should look like this:
- Open
- Place the Item on the Scene:
- Now that the item's been set up, you can place it anywhere on a scene by double-clicking it from the
Objects tab.
- Now that the item's been set up, you can place it anywhere on a scene by double-clicking it from the
- Test the Game:
- Run the project to verify the new item shows up and works as expected.
Creating a New Enemy
Follow these steps to add a new enemy to the demo:
- Create the New Enemy Graphic:
- Open
.Tools >Resources - Double-click the
Body Sprite Resource . - Select an empty tile, and click the
Import Images/Models icon or theImport Animation Frames one right next to it if you have multiple images forming an animation sequence. - Click the
Add Box Collision icon ("Shared with whole Tile") to add a new collision box to the sequencer. - Set up its size and line it up with the graphic.
- Follow the same procedure for the "Attacking" pose as well, if you want a different animation sequence to play when the enemy is attacking another.
- Open
- Set up the New Enemy:
- Load the
Scene Resource you want to place the enemy in. - On the
Objects panel, double-click theCharacter object to create an object based off of theCharacter class. - While the newly created object is selected, head down on its
Properties panel until you find theLayers property. Add a new layer to it by clicking+ once beside it. - Set the
Sprite value to theSprite Resource you created/imported the new enemy's graphic in, and theTile to which tile you created it on. The count starts from 0, so if you created it on the 3rd tile, its # would be 4. - Since this is supposed to be an enemy, set the
Team property toBad . - Make sure to also set up its
Statistics and enable AI by tickingAI Enabled at the bottom. - It also needs a weapon in order to be able to attack. This can be done with the
Equip Item function, preferably executed via the actor'sCreated Event .
- Load the
- Test the Game:
- Run the project to verify the new enemy shows up and behaves as expected.
If you think anything is missing, please feel free to: submit documentation feedback on this page