Can you replicate a struct with a pointer to an Actor

Is it possible to replicate a struct that has a pointer to a actor? Such as doing damage with a struct that contains a property for the damage instigator and the damage receiver? Would the client be able to reconcile the pointer?

#Yes

If the actor pointer you are replicating is pointing to an actor that is already set to bReplicates=true, then yes you can replicate that actor pointer in a USTRUCT

just make sure the Actor* is UPROPERTY()

Also make sure to set the pointer to null yourself since USTRUCTS wont do that for you and can cause your game to crash otherwise!

#Code For You

USTRUCT()
struct FYourNetStruct
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY() //<~~~ Required for replication
	AActor* ReplicatedActorPtr;
	//As long as this actor has bReplicates=true, this ptr will replicate properly
	// when this struct is passed over the network!
	
	UPROPERTY()
	float DamageAmount;
	
	UPROPERTY()
	FVector_NetQuantize100 HitLocation;
	
	FYourNetStruct()
	{
		ReplicatedActorPtr = nullptr;  //You must init this to avoid crashes -Rama
		
		HitLocation = FVector::ZeroVector;
		DamageAmount = 0;
	}
	
};

Hey could you please tell me what FVector_NetQuantize is?

RAMA! Thank you! This helps immensely with my design and my understanding of the source.

Actually birdfreeyahoo that was my next question as well haha. I assume it is a vector that describes the hit location, but my curiosity is peeked as to what the difference is between FVector_NetQuantize100 vs the basic FVector?

I am a replication newbe, i’ve read most of the tutorials but it is still a new way of thinking. I’m getting my head around it but it is very hard to find more complex C++ documentation except to dive completely into the source code and for some topics such as the prediction key stuff you just have to get lucky and stumble across an explanation in the source (such as the ability system prediction key).

Ah I’ve found it. You can find it in the documentation on FVector, there is also an answer hub question asking for confirmation. But in general it looks like

FVector - fully float based vector

NetQuantize - vector components have no decimal places

NetQuantize10 - has 1 decimal place

NetQuantize100 - has 2 decimal places

NetQuantizeNormal - only has a range between -1 to 1