System UnrealPlugin InferenceInterfaces Component - kcccr123/ue-reinforcement-learning GitHub Wiki
UInferenceModelActorComponents
is a UActorComponent
subclass designed to run inference on a per-frame basis within an Unreal Actor. It allows developers to attach trained model logic directly to gameplay actors, enabling autonomous behavior via ML policies.
This component is built to work with any implementation of UInferenceInterface
.
The component exposes a standardized inference loop in the form of TickComponent
. Each frame, it generates a state string, runs the model, receives an action, and applies that action to the actor.
This allows actors to behave autonomously without relying on bridge-based training logic, and is ideal for putting trained and exported policies to use.
- Add the component to any actor
- Set the inference interface with
SetInferenceInterface()
- Call
StartInference()
to enable ticking
Enables TickComponent
, which begins the inference loop. Should be called after a model has been loaded and set.
Disables ticking and halts inference evaluation.
Assigns the backend model interface (e.g., ONNX). Returns true
if valid.
Invokes RunInference
on the current interface using a formatted state string.
The following virtual methods must be implemented for the component to perform useful logic:
Construct a serialized representation of the actor's current state.
EXPECTED FORMAT:
"<obs_0>,<obs_1>,...,<obs_n>"
Used as input to the model.
Decode the returned model output and apply it to the actor (e.g., set velocity, trigger animation).
Return true
if the current action is still executing. Used to avoid spamming inference while actions are still playing out.
Internally handles the full inference loop each frame:
- If no action is currently running
- Serialize state using
CreateStateString()
- Run model with
RunLocalModelInference()
- Apply result using
HandleResponseActions()
- Set
bIsWaitingForAction
to true untilIsActionRunning()
returns false