Drawing using Canvas

Canvas is a continuation of the simple HUD implemented within Unreal 3. While it isn't so commonly used within shipping games, mostly being replaced by Slate/UMG, it's simple to use, especially when you want to draw text or shapes to the screen. Canvas drawing is still used extensively by console commands used for debugging and performance analysis such as the stat game and other stat commands. Refer to Chapter 8, Integrating C++ and the Unreal Editor, for the recipe for creating your own console commands.

How to do it...

  1. Open your <Module>.build.cs file, and uncomment/add the following line:
    PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
  2. Create a new GameMode called CustomHUDGameMode using the ...

Get Unreal Engine 4 Scripting with C++ Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.