Announcement

Collapse
No announcement yet.

Can a blueprint actor "hear" a C++ function firing in its components?

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

    Can a blueprint actor "hear" a C++ function firing in its components?

    I'm working on an item system, 99% of it takes place in C++ but I'm trying to use blueprint to create "holder" actors whose job is to retain a reference to my item struct until the player interacts with them and takes the item they're storing, at which point the actor itself needs to self-destruct (so it can't be looted again).

    I wrote an actor component which actually holds the item data and does all the heavy lifting to figure out if it can be looted, and gave it what I thought were two events that blueprint could see and subscribe to, the idea being that my C++ logic would detect when it needed to destroy itself, and fire an event to inform its actor of this fact:

    Code:
    UFUNCTION(Category = "Interaction", BlueprintImplementableEvent)
    		void PickedUp();
    
    		UFUNCTION(Category = "Interaction", BlueprintImplementableEvent)
    		void NotPickedUp();
    However, when I get a reference to my component in blueprint I can't see either of these events, even with the context sensitive turned off. Is there something I neglected to place in the UFUNCTION macro, or am I going about this in a fundamentally wrong way?

    #2
    I do this from the pawn and it works:
    Code:
    UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "MMT Physics Tick"), Category = "MMT physics sub-stepping")
    void MMTPhysicsTick(float SubstepDeltaTime);
    Have you tried to find this event in the blueprint of the component itself instead of trying to call it from a reference to component?
    Youtube Channel

    Comment


      #3
      Hmm that's weird, I copied & pasted directly from your example and it still won't show up, so it's definitely something funny that I'm doing. Per your second question, and probably directly related to the problem, I don't actually have a blueprint of the component; it's a C++ component that I mark as a BlueprintSpawnableComponent in its UCLASS macro, but if I right-click on it in the content browser "Create blueprint class based on..." is greyed out for every class of type UActorComponent.

      That being the case, I just made an actor BP and added my class through the Add Component tab. It works fine and everything, it just can't actually see the implementable events I'm adding.

      Comment


        #4
        Perhaps your c++ component have to be marked as blueprintable for your event to be blueprint implementable. Unfortunately I don't have any macro example for blueprintable component, but source of ActorComponent or SceneComponent should have such macro.
        Youtube Channel

        Comment


          #5
          Hmm okay, thank you

          Comment


            #6
            Originally posted by HInoue View Post
            Hmm that's weird, I copied & pasted directly from your example and it still won't show up, so it's definitely something funny that I'm doing. Per your second question, and probably directly related to the problem, I don't actually have a blueprint of the component; it's a C++ component that I mark as a BlueprintSpawnableComponent in its UCLASS macro, but if I right-click on it in the content browser "Create blueprint class based on..." is greyed out for every class of type UActorComponent.

            That being the case, I just made an actor BP and added my class through the Add Component tab. It works fine and everything, it just can't actually see the implementable events I'm adding.
            One thing, code of the event that I have is declared in custom Pawn, not in custom component.
            Youtube Channel

            Comment


              #7
              Yeap, I forgot about this:
              https://answers.unrealengine.com/que...nt-events.html

              mechanism for components is different!
              Youtube Channel

              Comment

              Working...
              X