Announcement

Collapse
No announcement yet.

Component event not visible in blueprint?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Component event not visible in blueprint?

    Hello! So I have custom component that I can add to my blueprints, within this component I have an event.


    Code:
    UFUNCTION(BlueprintImplementableEvent, Category = "Interaction")
    void InteractEvent();
    This works fine when I add events within the actors the blueprint is a child of, but turns out it does not appear the same way when it's a part of an added component instead.
    Click image for larger version  Name:	2020-11-23 00_14_04-PalisadeGate_BP.jpg Views:	0 Size:	143.7 KB ID:	1835071
    How would I make a component's events available in blueprint?

    It shows up if I make it a callable function, but not as an event.
    Last edited by Graylord; 11-23-2020, 08:28 AM.

    #2
    Just add a BlueprintCallable after BlueprintImplementableEvent flag, with which could be called in BP.

    Comment


      #3
      I tried that, but that makes it show up as a callable function, not an event.

      Click image for larger version  Name:	2020-11-23 12_56_53-PalisadeGate_BP.jpg Views:	1 Size:	51.4 KB ID:	1835217
      (Renamed it to Trigger interaction for better clarity)

      I need to trigger it as an event in my blueprint, which I do from C++.
      Last edited by Graylord; 11-23-2020, 08:03 AM.

      Comment


        #4
        Code:
        UFUNCTION(BlueprintImplementableEvent, Category = "Interaction")
        void InteractEvent();
        This is fine, but instead of dragging out from the "Interaction" variable in blueprint, you can find the event in the right click menu.
        Working on King Arthur: Knight's Tale.

        Comment


          #5
          Thanks but I'm afraid not, I've done it this way before when implementing events in actors directly without issues.

          But now that it's a part of a component that's added in blueprint instead, it doesn't seem to show up.
          It doesn't show up in the list of events under the component's details tab either.

          The component is pretty much just a child of BoxComponent with my custom event, if that helps.
          Click image for larger version  Name:	2020-11-24 18_51_20-PalisadeGate_BP.jpg Views:	0 Size:	84.0 KB ID:	1835750
          Last edited by Graylord; 11-24-2020, 02:37 PM.

          Comment


            #6
            If I make the component blueprintable and make a new blueprint based on it, the event appears, however that defeats the purpose of having it as an optional component to attach to other blueprints.

            So it's definitely related to it being a component and not the base class of the blueprint.

            Code:
            #pragma once
            
            #include "CoreMinimal.h"
            //#include "Components/SceneComponent.h"
            #include "Components/BoxComponent.h"
            #include "InteractionComponent.generated.h"
            
            
            UCLASS(Blueprintable, ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
            class TRIBESMEN_API UInteractionComponent : public UBoxComponent
            {
            GENERATED_BODY()
            
            public:
            // Sets default values for this component's properties
            UInteractionComponent(const FObjectInitializer& ObjectInitializer);
            
            protected:
            // Called when the game starts
            virtual void BeginPlay() override;
            
            public:
            // Called every frame
            virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
            
            //UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Collision)
            // UBoxComponent* CollisionComp;
            
            
            UFUNCTION(BlueprintImplementableEvent, Category = "Interaction")
            void TriggerInteraction();
            
            };
            Edit: I was finally able to work around it, but it seems rather excessive and "hacky".
            Instead of using a blueprintable event, I made a delegate that I broadcast, and bound the delegate (which luckily showed up) to a custom event.

            But it feels inefficient to make a function that constantly listens for a broadcast, instead of just having it trigger on use.
            Last edited by Graylord; 11-26-2020, 09:15 PM.

            Comment

            Working...
            X