Multicast delegate not showing up in Blueprint

So I’m trying to create an event accessible in Blueprint from a custom component. As I understand it from reading many of the answers here, that’s only doable using a multicast delegate.

So I set out to do this. My .h file is as follows:

#pragma once

#include "Components/ActorComponent.h"
#include "CharacterTrigger.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnTriggerEnterSignature);

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class MYGAME_API UCharacterTrigger : public UActorComponent
{
	GENERATED_BODY()

public:
	// Sets default values for this component's properties
	UCharacterTrigger();

	// Called when the game starts
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) override;

    UPROPERTY(BlueprintAssignable, Category="Custom")
    FOnTriggerEnterSignature OnTriggerEnter;

    UFUNCTION()
    void TriggerEnterCheck(AActor* Other);

    UFUNCTION()
    void TriggerExitCheck(AActor* Other);
};

However OnTriggerEnter does not show up under Collision when right click on a blueprint for an Actor with a CharacterTrigger on it. Am I missing something?

Thanks!

Hey -

What exactly are you trying to do? If you are simply trying to use blueprints to call a function written in code then you only have to use the BlueprintCallable specifier in the UFUNCTION() macro. Any function defined as BlueprintCallable also has to have a Category. This will allow the editor to recognize the function so that it shows up in the blueprint event graph. It is similar behavior for a variable as well. In the UPROPERTY() macro you use the BlueprintReadWrite specifier to see and edit the variable inside the blueprint.

Cheers

I want to have an event node that I can call from code attached to a component I define in code. I want that event to be defined by the component because it will be a common event used throughout the game.

This has been described elsewhere eg in this Answer:

Hey -

Following the post you referenced will provide the event in the details panel when the component is selected inside a blueprint. In your case when you select your CharacterTrigger component inside a blueprint you should see the OnTriggerEnter function at the bottom of the Details panel. If you want the function to appear when you right click and type in the name then you’ll want to make the function BlueprintCallable inside the UFUNCTION() macro.

Cheers

Ah thanks. But that would be for calling native code from Blueprints (a blue node). What I want is a red node, for triggering a blueprint event from native code. I’d like to add a basic event like one of the built in ones such as On Destroyed or On Clicked. As I understand it the normal way of doing this is using BlueprintImplementableEvent, but that is only usable for Actors not Components. For components I need to use DECLARE_DYNAMIC_MULTICAST_DELEGATE as described here:

and here:

Am I understanding this wrong?

Hey -

I’m still unclear on the result you’re after. When I look at OnDestoryed in the editor it gives me the option to bind a custom event to it.

58136-ondestroyed.png

When doing so, rather than appearing as a red event node it shows as a blue function node with an Event pin to bind the custom event to.

58137-destroyevent.png

Are you referring to a setup in this fashion or do you mean an event node such as Event BeginPlay or Event Tick?

Instead of using OnBeginOverlap in level blueprints, I’d like to create my own version of it that only fires when a specific set of criteria are met (criteria that I’ll check for in code before determining whether or not to fire the event).

So essentially, I’d like to be able to create a red node like the following in a level blueprint:

58175-1.jpg

And have that red node be available in the right click menu like this:

58176-2.jpg

Thanks! :slight_smile:

Hi ,

I think I may know what you are getting at. If you want to get a custom code event that will give you a Blueprint node to use, you would want to use something similar to the following:

UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "TriggerEnterCheck"), Category = Collision)
void TriggerEnterCheck(AActor* Other);

This will give you the following search results in a Blueprint:

58631-search.png

And the following node:

58632-node.png

Does that help?