Component events arrive in wrong actor when actors are duplicated

Here is a new project illustrating the bug:

Bug description:

I have a pawn base class and an actor component, both written in C++. The pawn base class is equipped with the actor component, which has a dynamic delegate, broadcasted in the Tick() function. This broadcast event also passes the owner of the component.

When I create a derived blueprint from the pawn base class, put it into the scene and duplicate it, the event is called on both actors, the owner is wrong one one of them, though.

In our project the event was a “HealthDepleted” event of a HealthComponent and all duplicated actors got the event of the one actors whose health was depleted. This only happens if the actors are duplicated in the editor. It works fine when I drag them into the scene one by one.

Steps to reproduce:

  • Create a new C++ project.
  • Create a new C++ Pawn class.
  • Create a new C++ ActorComponent class.
  • Add a OneParam dynamic multicast delegate to the actor component and broadcast it with the owner as parameter in the Tick() function.
  • Add the actor component to the pawn by using CreateDefaultSubobject() in the constructor.
  • Compile and switch to the editor.
  • Create a blueprint based on the pawn class.
  • Create another blueprint based on the derived pawn blueprint.
  • In this blueprint print out the actor that arrives with the event fired in the actor component.
  • Create an instance of this blueprint by dragging it into the scene.
  • Duplicate this instance several times.
  • Select Play in Editor, Stop and examine the output in the console.
  • Notice that the owner printed out does not match the actor the event is called on.

Hey HCK-

I have entered a bug report about the delegate being called twice (UE-25531) for further investigation. As you pointed out, the best solution for now is to drag in a second instance from the content browser rather than duplicating an already placed object.