A dev might want to move an AActor or APawn in the server and expect to see the movement reflected in the remote clients. He checks the ‘Replicates’ flag, moves the actor/pawn on the server and then spends hours trying to figure out why it didn’t do anything on the remote clients.
I see many posts about this in these forums, never with an answer or explanation, and many people wasting hours and hours of development time because the feature they see listed in the documentation doesn’t really exist. Certainly not as advertised.
If I’m supposed to propagate the actor’s movement to remote clients through an RPC, or the feature only works with Blueprints (haven’t tried it), that should be on the docs. If Epic intends to only support people using a UCharacterMovementComponent or ACharacter for actor movement, that should be there as well.
Sometimes people say, “but with ACharacter you get client-side prediction” which is saying Epic’s way is the only way and to hell with modular design (isn’t the point of components to adhere to modular design?). ACharacter is a total mess of random features, functions, and voodoo values stirred into a soup of chaos. If I want to use AActor to get rid of a lot of that bloat and crap that I’m not using and adhere to clean modular designs, I shouldn’t be penalized for it.
Here’s a sample test if you’re curious: A Simple AActor - NOT ACharacter, NO UCharacterMovementComponent- with the replication flag on and which moves itself on the server. Result: The actor moves on the server but not on the remote clients. I.E. The ‘Replicates’ flag does nothing, as far as devs can see.
Header:
UCLASS()
class TESTPROJ_API ATestRepActor : public AActor
{
GENERATED_BODY()
public:
ATestRepActor();
virtual void Tick( float DeltaSeconds ) override;
float TestTime;
};
CPP:
ATestRepActor::ATestRepActor()
{
PrimaryActorTick.bCanEverTick = true;
TestTime = 3.0f;
}
void ATestRepActor::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
if (Role == ROLE_Authority)
{
TestTime -= DeltaTime;
if (TestTime <= 0.0f)
{
TestTime = 3.0f;
FVector Temp = GetActorLocation();
Temp.X += 10.0f;
SetActorLocation(Temp);
}
}
}