Okay to use "this" keyword in constructor/header?

So inside the constructor of some actor class I’d like to code something like this:

  TargetInfo = FTargetInfo(this, 1, true); // is this line okay?

But is that proper? Of course I assume that initializing it in the header makes more sense but putting a this there feels even more awkward (it compiles and probably works):

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Turret01|IDamageable")
FTargetInfo TargetInfo = FTargetInfo(this, 1, true);

This will probably work just fine because TargetInfo is a struct but if TargetInfo were to be another actor or a class that references this class again then I would probably have to initialize it in the BeginPlay() instead.

I did find one issue with it so far however (but this is more related to having a reference to self). Anytime I delete a turret with that code in the editor I get this warning:


Obviously the warning makes no sense for self-references but I guess that UE4 does not check for that prior to throwing such a warning. I suppose there is no metadata to prevent this warning.

As for the reason for me using a reference to self in the struct: It saves some performance later and I have to use structs instead of interfaces because UE4 does not work well with interfaces in certain cases (no support for UPROPERTY in my case and interfaces in TArrays don’t seem very stable when sorting and such).

That’s odd ! I would think UE Check the case where there is a self ref…
using this in ctor isn’t a problem.

i don’t use the this in header, it feel so strange ( maybe it work fine )

Closing the question since this is something that needs to be changed in the editor (or allow us to suppress the warnings with metadata).