The StateMachineClass is a subclass of USMInstance, and YourContext is the object the state machine should run for. Just call Start() when you are ready.
Memory Management
Make sure you assign your instance to a UPROPERTY! The instance is a UObject and may be garbage collected by Unreal Engine otherwise. When you do want it garbage collected, null out the reference and make sure there are no other strong references to it.
Logic Driver Pro supports designing custom node classes through C++. See the Pro Quickstart Guide. You will still need to use the state machine blueprint editor to design the state machine itself.
Below we extend USMStateInstance which is a state class that can be placed in a state machine graph. Notice that OnStateBegin_Implementation, OnStateUpdate_Implementation, and OnStateEnd_Implementation are overidden. This allows you to execute state logic in C++ rather than blueprints. See the USMStateInstance class for all virtual _implementation methods you can override.
#pragma once#include"CoreMinimal.h"#include"SMStateInstance.h"#include"SMNativeStateNode.generated.h" // Your filename.generated.hUCLASS(Blueprintable,BlueprintType)classYOURGAME_APIUSMNativeStateNode:publicUSMStateInstance{public:GENERATED_BODY()protected:virtualvoidOnStateBegin_Implementation()override;virtualvoidOnStateUpdate_Implementation(floatDeltaSeconds)override;virtualvoidOnStateEnd_Implementation()override;};
Below is an example implementation of OnStateBegin and how to use the context passed into the state machine.
voidUSMNativeStateNode::OnStateBegin_Implementation(){// If your context is your character we can use it just like in blueprints.if(ACharacter*CharacterContext=Cast<ACharacter>(GetContext())){CharacterContext->DoStuff();}}