I would like to create an actor (building with walls and doors).
In this actor, I want to add a ‘door actor’ with blueprints, and a few wall actors.
When I click one of these doors, I want to run the OnClick event of this door actor (so it will open and close) and also the OnClick event of the actor that I put the door actor in.
I am probably doing something wrong, so any help is appreciated!
hmm. I’ve not really used child actor components very much, but my guess is that there’s not really any sort of waterfall/cascade situation there – whatever you click on is what you click on, and that’s that.
You could have the child call OnClick in the Owner?
Have an EventDispatcher in the door actor delegate the click to the child actor component owner.
Or use an interface to fire owner’s event. There is a node (get parent actor, I think) that returns the actor who owns the CAC.
When it comes to the abovementioned cascading - kind of. UE refers to it as tunneling / bubbling often. It’s a matter of input consumption. Can’t recall if onClick events have a switch for that but I’d stay away from it in this scenario anyway.
Also, must the doors / walls be actors? If you want them run logic and hold state data, perhaps it’s enough to extend a static mesh component. Handy, more user friendly and much lighter on the resources.
But there are scenarios where CAC is a must, ofc; hard to tell if they are the necessary evil (because they get fussy) here without knowing more. Judging by the description and intent, I’d say not yet.
u can’t run a event directly by child actor component
drag the pin from child actor and use get child actor then u can do what ever u want cast , event dispacher or use interface like you do with normal actors
example :