Debugging

Our game is now ready for testing and tweaking.

The Architect lets us build the game and play the game. It also has a set of debugging tools that allow us to “drill down” into entities and components in real-time, providing a clearer snapshot of what’s going on while the game is running.

In this section, we’ll:

  • Start the game
  • Move the player character
  • See how the debugger can help us find appropriate values for our Agent
  • Update the Agent component with these values

Start the game

  1. Press F5 to start the game.

  2. Press Enter to select New Game and begin gameplay.

    Gameplay

Move the player

  1. You should now be able to move the character around with the arrow keys, WASD, or the gamepad.

    One thing you may notice is that the character doesn’t stop when you let go of the control. This occurs because we left the Friction at 0.0.

    Point your character into a wall before letting go of the directional input, and you will see that the Collider stops it from proceeding any further.

    If your character doesn't move at all, we can fix that in step 9.
  2. Press F1 to pop up the Console, which shows any logging messages that may occur:

    Gameplay - Console

  3. Close the Console by pressing F1 again.

Debugging Tools

  1. Press F2 to pop up the debug panes.

    These panes may pop up expanded; you can collapse them by clicking the down-arrows at the top left of each pane.
  2. Then, click on the player entity.

    The debug panel should show up, showing all the components on the selected entity:

    Gameplay Debugger - Player selected

  3. Now, try to move the character around with the cursor keys or gamepad.

    Notice that, while your character is moving, the debug pane will show an Agent Impulse component and a Velocity component. This is how you know the ECS engine is hard at work.

    Take note that if your mouse is pointed at a menu, your keyboard input will not be sent to the game.

Update the Agent

  1. Click on the Agent component. You should see that it has the same properties you set within the Architect.

  2. Adjust the Agent settings and play around with the character. This is how you can debug your ECS character in real time.

    Ensure the Speed and Acceleration are positive numbers.

    Adjust the Friction to 1.0.

    Gameplay Debugger - Adjusted settings

  3. Once the agent motion controls feel right, take note of the new Speed, Acceleration, and Friction settings.

  4. Press F5 to leave Play mode.

  5. Unfortunately, any edits you made in Play mode have been lost. Apply your new Speed, Acceleration, and Friction settings we took note of in step 11 to the Agent component in the Player prefab.

  6. Press Save Asset to lock in the changed settings.

Finishing up

Great work! That’s the basic loop for working with the Murder engine:

  1. Modify or build Components and Systems in C#
  2. Add/modify them in the Architect
  3. Test in Play mode until it feels right
  4. Repeat until your game is done

Now it’s time to start building your game!