I tried making an Multi-Action Input Actor Component, and I made the Event inside my CPP. class. Thing is it doesn’t show up in Events tab. I tried recompiling it in VS but that’s not working either.
Am I missing something?
UCLASS(ClassGroup=(Input), meta=(BlueprintSpawnableComponent))
class MY_API UMultiActionInput : public UActorComponent
{
GENERATED_BODY()
protected:
// Called when the game starts
virtual void BeginPlay() override;
// #CUSTOM EVENTS START (No need to create Definitions for them, despite warnings.)
//
UFUNCTION(BlueprintImplementableEvent)
void CE_MAIA_Trigger_Hold();
//
UFUNCTION(BlueprintImplementableEvent)
void CE_MAIA_Trigger_Tap();
//
UFUNCTION(BlueprintImplementableEvent)
void CE_MAIA_Trigger_Release();
// #CUSTOM EVENTS END
};
BlueprintImplementableEvent and BlueprintNativeEvent are functions
What you’re looking for is DELCARE_DYNAMIC_MULTICAST_DELEGATE, and then create a UPROPERTY(BlueprintAssignable) property of the delegate that you created
LIke I said, it has to be a DECLARE_DYNAMIC_MULTICAST_DELEGATE to work with blueprints
I would suggest you look in the engine’s source code for things like that, there are infinite examples, and you can easily look up something that you’ve seen and want to replicate in the engine to see how it’s done
I declared the event first. Then I changed the UPROPERTY from ImplementableEvent to BlueprintAssignable in Header.
Header
// #DECLARES START (No need to create Definitions for these Delegates, despite warnings.)
// Declare CE - Multi Action Trigger (Hold)
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FDEC_MAI_Trigger_Hold);
// CE - Hold Action
UPROPERTY(BlueprintAssignable, Category = "Events (Multi-Action)", meta = (DisplayName = "On MAI Trigger (Hold)"))
FDEC_MAI_Trigger_Hold On_MAI_Trigger_Hold;
void CE_MAIA_Trigger_Hold();
Then here’s what I did in CPP.
// Broadcast Delegate - Hold
void UCndMultiActionInput::CE_MAIA_Trigger_Hold()
{
On_MAI_Trigger_Hold.Broadcast();
}
Alright, I figured it out somehow.
NOTE: Retriggerable Delay is not allowed in Functions. Use Timers instead.
First, I needed to create a Timer Handle in Header.
Header (h.)
private:
// Make Timer Handle for Delay
FTimerHandle MAI_TimerHandle;
Then in the source, set up a Delay Timer and Extra Function.
Source (CPP.)
void UMultiActionInput::BP_MAI_On()
{
// Delay: Set up a timer - MAI_TimerHandle
GetWorld()->GetTimerManager().SetTimer(MAI_TimerHandle, this, &UMultiActionInput::BP_MAI_Hold_Trigger, MAI_HoldDuration, false);
}
void UMultiActionInput::BP_MAI_Hold_Trigger()
{
// This function will be called after MAI_HoldDuration seconds
CE_MAIA_Trigger_Hold(); // Call Event if Input is still held
}
void UMultiActionInput::BP_MAI_Off()
{
// This function will is to be called, if held Action Button is Released
// Delay: Clear the timer - MAI_TimerHandle
GetWorld()->GetTimerManager().ClearTimer(MAI_TimerHandle);
}