Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Blueprint Implementable Custom Component Events?

I'm trying to create custom actor components which have implementable events. I have a basic unit class and a basic spell class, and I want to be able to create custom blueprints from those to make different types of units and different spells.

alt text

I have a few events I want to be able to implement such as "OnCastBegin", "OnCastSuccess", and "OnCastFailure" etc. Here's the full code for my ability's header class:

 #pragma once
 #include "KBuff.h"
 #include "KAbility.generated.h"
     - Active Component: the action which happens if the ability is activated. An ability may or may not have an active.
     - Passive Component: the passive effects of the ability. An ability may or may not have passive effects.
 class AKBasePawn;
 UCLASS(ClassGroup=(Ability), meta=(BlueprintSpawnableComponent))
 class KIDSOFTHEWOODS_API UKAbility : public UActorComponent
     UFUNCTION(BlueprintImplementableEvent, Category = "KAbility")
     void OnCastBegin();
     UFUNCTION(BlueprintImplementableEvent, Category = "KAbility")
     void OnCastFail();
     UFUNCTION(BlueprintImplementableEvent, Category = "KAbility")
     void OnCastSuccess();
     UFUNCTION(BlueprintImplementableEvent, Category = "KAbility")
     void OnTargetHit(const AKBasePawn *Target);
     UFUNCTION(BluePrintCallable, Category = "KAbility")
     void ActivateAbility();
     AKBasePawn *owningUnit;
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "KAbility")
     float castTime;
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "KAbility")
     UKBuff *passiveAbility;

When I look at the static mesh reference of my blueprint, it has a ton of implementable events such as OnMouseOver, OnClicked, etc. I can't figure out how to do that for my component.

Product Version: UE 4.8
untitled.png (228.4 kB)
more ▼

asked Jul 18 '15 at 11:56 PM in C++ Programming

avatar image

199 13 18 35

avatar image Slowmanrunning Jul 19 '15 at 07:26 AM

I found that UPrimitiveComponent does the events I mentioned as follows:

 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam( FComponentBeginCursorOverSignature, UPrimitiveComponent*, TouchedComponent );
 //then further down...
 UPROPERTY(BlueprintAssignable, Category="Input|Mouse Input")
 FComponentBeginCursorOverSignature OnBeginCursorOver;
avatar image fudo Dec 11 '15 at 05:23 PM

Is there a way to do the same via blueprint? I mean, a custom blueprint-made component.

avatar image sdouce_playwing Aug 03 '18 at 06:45 PM

Add an Event Dispatcher and copy the Signature from the custom event you created.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

So I found out in order to have component events available to you in blueprints requires a dynamic multicast delegate--or at the very least a dynamic delegate, I haven't tested whether that works as well.

alt text

The code to do this is as follows:

 #pragma once
 //include headers
 #include "UCustomComponent.generated.h"
 UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
 class MYGAME_API UCustomComponent : public UActorComponent
     UPROPERTY(BlueprintAssignable, Category="Custom")
     FComponentCustomStartSignature OnCustomStart;

Do that, and your events should show up under events like in the bottom right corner of the picture.

untitled.png (202.1 kB)
more ▼

answered Jul 20 '15 at 08:44 AM

avatar image

199 13 18 35

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question