Table of Contents

Power Network: User Events

Keyboard Inputs

There are several ways to configure user-defined events in the Unreal Engine. One such example is using an Input Event from the keyboard. When a specific button is pressed during the simulation, some code can be executed. In this tutorial, when the C button is pressed, the camera will take an image of its current surroundings and save it to a directory. To configure the event, type Keyboard in the blueprint search on the Event Graph of the level blueprint.

Untitled

Warning

Keyboard events can only be added to the event graph of the blueprint. These options will not appear if attempting to find the events from a function outside of the event graph.

When the appropriate event is selected, the button can be changed by selecting the event and then pressing the keyboard icon in the details panel and then pressing the key that is required. Whenever the key is pressed down, the code following the execution pin will be called.

Untitled

Note

The event will only be called when the key is pressed or released (depending on the pin used). For checking if the key is held, the check for the key will need to be done on the Tick event instead and cannot be called from an input event.


Image Capturing

When the keyboard event is executed, a new function named Capture Image will be created and called. This function will attempt to take an image of the Earth from the camera. The logic for handling the power system will be demonstrated in the next document, but for now, the camera can take a photo using the Capture to File function. The name of the file is the name of the image (without the extension) that will be saved when the capture is taken.

Untitled

When the simulation is run and the C button is pressed, an image will be saved and displayed on the camera widget in the UI. To view the image in the directory, open up File Explorer and navigate to the /Saved/ directory of the Nominal Editor project. This is the default directory for where images from cameras are saved, with the appropriate file name provided.

Note

The current capture system may output images that can appear darker than they are displayed on the screen. This is dependent on the file format that is selected on the camera configuration parameters.