issues with AddUnique and arrays

TArray requires Type (AActor in this case) to be publicly copy constructible (public T(const T&) constructor), whereas AActors copy constructor is private. On top of that, AddUnique requires operator==(const T&) const to be defined, which AActor doesn’t have.

Apart from that, by dereferencing a pointer when adding it to an array, you would be creating a copy of the pointed object, thus the object in the array would not be the same that you added (well, it would be a copy of it, but it would no longer be the same object).

I would recommend changing the type of the TArray from AShooterCharacter to AShooterCharacter* and storing a pointer to that object CharacterHitResult.AddUnique(HitCharac);

1 Like