Skip to main content

Creating Device Actor

In order for the Operating System to work, you need a device which requires a device actor to construct it. There are two device actors in Operating System Plugin and they are:

  • Device Actor - Simulates stationary device such as computer.
  • Portable Device Actor - Simulate portable devices such as laptop, mobile, tablets or anything that requires battery.

Device Actor​

In this section, we will create a new device actor which is used to construct our device.

To create a new device actor, right click inside Content Browser, select Blueprint Class. From the resulting window search for device actor and select it.

Pick parent class screenshot

So the error is stating the obvious. There is no designated device class, so that is what we will do.

Portable Device Actor​

note

Added in v3.5.0

If you prefer to have a portable device, simply select Portable Device Actor from the prompt window.

Pick parent class screenshot

Portable device has additional battery settings that you can configure from the details panel. Let's take a quick look at it.

screenshot

SettingDescription
Has BatteryDetermines if this device has an equipped battery. If this is false, this device will not start.
Battery LevelStarting battery level. If 0, device won't start unless Begin Charging Battery is called.
Battery Consume DelayDelay in seconds to consume 1 battery level if not charging.
Current Battery - Battery NameUser facing battery name.
Current Battery - Battery BrandUser facing brand name.
Current Battery - Battery Capacity (mAh)Total capacity of the battery in milli-amp-hour unit
Current Battery - Charge RateCharging Speed. Higher numbers charge faster.
Current Battery - Efficiency LossSimulates energy loss while charging. Higher means more time to charge. For example: A battery with 3200 mAh and charge rate of 1000 mA will take 3.2 hours to fully charge without energy loss. With 40% energy loss it would take 4.5 hours to fully charge.
Low Battery Warning LevelEmits a warning signal if battery level goes below this value.
Battery Save State FlagsA bitmask enum where you can choose multiple states of battery to trigger save game. E.g: if you select Battery Consume and Battery Charge, game will be saved automatically whenever battery is consumed or charged each level.

Portable device comes with it's own set of functions for battery such as charging, stop charging and setting battery. screenshot

They also emit events natively from C++ side so you can simply listen to them anywhere via Device Messenger object to react accordingly. The Payload will be the portable device actor. screenshot

Creating the Device Actor​

For the sake of this tutorial, you can choose Device Actor (feel free to select portable if you want to). Rename it to BP_Tut_DeviceActor. Open this newly created device actor and leave everything at default for now. Drag and drop this actor into an empty world and press play. You'll notice that nothing is happening. If you check the log, you will see a following message:

Device error in BP_Tut_DeviceActor_C_1: ERR_DEVICE_CLASS_NULL. Exception: Device Class is null
log - your trusty friend

If something is not working as intended, always check the log first.