Documentation

Demo - 3D Platformer - Open Dev Kit Documentation

Open Dev Kit Documentation :: Demo - 3D Platformer

3D platformer game with moving platforms and enemies utilizing OpenGL and Jolt physics.

How it Works

  • Game Initialization
      Upon starting the game, the Start function is triggered. This initializes the StartingMap Scene and the player's starting location via the Scene Add function, which derives this data from the gSettings variable that can be accessed via the Game Settings menu in the main toolbar.
      After some essentials are done initializing, the Start function calls the Start 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" has Pause 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 a Scene Add function with an Input Type parameter set to Regular Game, meaning when the specified Scene gets added the Regular Game Keybind also becomes active.
      The reason the player still cannot move however is because afterwards the Start Game function gets called which executes a Message Box function with the Can Close parameter ticked (set to 1/true). The Message Box function also has a Scene Add function with an Input Type parameter set to Interface, meaning when it gets executed, the Interface Keybind will exclusively become active.
      When the player hits the "Enter" key to close the message boxes, the Accepted Event of the Message Box Scene is triggered, which executes a Scene Remove function that calls Update Active Inputs, a function which updates which inputs should be enabled based on current active Scenes.
  • Active Scenes
      The 3D Platformer demo has an 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 the SceneAdd and SceneRemove functions.
      • SceneAdd adds a Scene to the current list of active Scenes and defines how the Scene interacts (overlay or parallel), and even determines input behavior when the Scene is active,
      • while SceneRemove removes a specific Scene from the active list, while also automatically shifting interaction focus to the next available Scene (useful for closing UI elements/menus and transitioning back to gameplay).

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:

  1. Create the New Item:
    1. Open Tools > Resources.
    2. Double-click the Collectables Sprite Resource.
    3. Copy the existing heart model and paste it over to a blank tile.
    4. Click on it to select it on the sequencer and set its Color to preferably yellow.
    5. 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.
  2. Set up the New Item:
    1. Open Tools > Globals / API.
    2. 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.
    3. After pasting it, change its graphic to the new heart by setting the Default value of its Layers property to {{Sprites/Characters/Collectables,2,{1,1,1,1},-1}}. This will grab the graphic from the 3rd tile of the Collectables Sprite Resource, which is the new golden heart.
    4. Set up its functionality by editing the script of the Collision Actor Started Event.
    5. Add a Change Max function before the existing Change 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
    6. If you want the player's HP to also be replenished, keep the Change Current function, but for its Value use char.mStatistics.mHP.mMax instead.
    7. The updated script should look like this:
  3. 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.
  4. 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:

  1. Create the New Enemy Graphic:
    1. Open Tools > Resources.
    2. Double-click the Body Sprite Resource.
    3. Select an empty tile, and click the Import Images/Models icon or the Import Animation Frames one right next to it if you have multiple images forming an animation sequence.
    4. Click the Add Box Collision icon ("Shared with whole Tile") to add a new collision box to the sequencer.
    5. Set up its size and line it up with the graphic.
    6. 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.
  2. Set up the New Enemy:
    1. Load the Scene Resource you want to place the enemy in.
    2. On the Objects panel, double-click the Character object to create an object based off of the Character class.
    3. While the newly created object is selected, head down on its Properties panel until you find the Layers property. Add a new layer to it by clicking + once beside it.
    4. Set the Sprite value to the Sprite Resource you created/imported the new enemy's graphic in, and the Tile 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.
    5. Since this is supposed to be an enemy, set the Team property to Bad.
    6. Make sure to also set up its Statistics and enable AI by ticking AI Enabled at the bottom.
    7. 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's Created Event.
  3. 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