Original Discord Post by ham1ton | 2024-09-17 16:09:48
Is it possible to know if an action was fired without having to have a function by the same name? Say I want to know if an arbitrary action was called that the NPC may not have a function for, is there a way to know what action is being called by it’s name? I’m using Unreal but I imagine this question is relevant to more than just Unreal.
Thanks!
Yes, you can use the OnActionReceived delegate in the ConvaiChatbotComponent, which will provide you with all the data related to the actions being called.
Great suggestion thanks! I actually just made my own delegate call out from the chatbot component, this way I don’t have to sort through the actions. Since I work in Unreal 4 I’ve had to heavily modify the plugin anyways to get it working, This is what I did"
ConvaiChatbotComponent.h:
/**
Added the FOnActionHasNoEvent declaration
Param Action name ( Action with no matching event or function)
**/
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnActionHasNoEvent, FString, ActionName);
public:
UPROPERTY(BlueprintAssignable, Category = "Convai", meta = (DisplayName = "On Actions ReceivedNoEvent"))
FOnActionHasNoEvent OnActionHAsNoEvent;
ConvaiChatbotComponent.cpp:
/**Added the OnActionHAsNoEvent.Broadcast this is an event disbatcher callable from the convai chatbot object.
the current use case is having the ability to know if the character has spoken on topics necessary for the completeion of scenerio objectives.
**/
bool UConvaiChatbotComponent::TriggerNamedBlueprintAction(const FString& ActionName, FConvaiResultAction ConvaiActionStruct)
UE_LOG(ConvaiChatbotComponentLog, Log, TEXT("TriggerNamedBlueprintAction: Could not find an event or function with action name: %s"), *ActionName);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Purple, (TEXT("Action Name : %s "), *ActionName));
OnActionHAsNoEvent.Broadcast(ActionName);