How to compare DataAssets safely?

Suppose I have:
class UFaction : UDataAsset
{
//various fields defining faction stuff
}

And now on an actor I may have a reference to which faction they belong to:
UPROPERTY(EditAnywhere)
UFaction* Faction;

If I had two actors, what would be a safe way to decide if they belong to the same faction? If I just compare the pointers am I guaranteed that they will be the same if they were assigned the same faction asset in the editor?

Use name comparison:

if (FactionA->GetFName() == FactionB->GetFName())
{
... same faction
}

Hi,

We think this post contains useful information which we would like to share with our public UE4 community. With your approval, we would like to make a copy of this post on the public AnswerHub which includes the discussion but strips out your username and company name. Please let us know if you are okay with this.

Thanks!

Sorry, I meant CDO name, so

if (FactionA->GetClass()->GetDefaultObject()->GetFName()....

Hi, no problem you’re welcome to share this.