How do you override a primitive component's events on your actor?
I have an actor that has a box component inside of it. How can I override the box's OnClicked event in the same way that I can override the actor's "ReceiveActorOnClicked" event? At least I think that that is the right actor event, I'm new to the C++ side of UE4.
If I were to override the actor's version, I would use this as a signature in the header file -
However, I have no idea how to do the same thing for the box component.
I've attached a screenshot to show which event specifically I'm looking to override.
You are right on the actor side, which using you custom actor you just overwrite. For the component you should do the same, create you own component that inherits from the one you use and then you can overwrite it.
In case you want to replace the actor (for example a Pawn or a Character) you have to tell the engine to not spawn the default version of the component so you can take care of specifying your own. Most of the components of the base engine classes are created using 'CreateOptionalDefaultSubobject' so that
This is done passing on the PCIP within your custom actors constructor a function chain telling the super class which components should not get created with its default types, this is achieved using the 'DoNotCreateDefaultSubobject' function. Then in the same constructor you create it using your own using 'CreateDefaultSubobject' to force that no child classes can prevent the creating or using 'CreateOptionalDefaultSubobject' so you could again change the components in other child classes.
An example can be found in the constructors of 'ACharacter', 'APawn' and 'APaperCharacter' which prevents the creation if the character mesh component that comes from 'ACharacter'.
If you have more questions just post them.
Hope I could help!
Follow this question
Once you sign in you will be able to subscribe for any updates here