Hiding replicated actor on owning client to remove the Lag

Hello,

I would like to hide the replicated actor from the local player. If i spawn a actor from the server RPC and this actor is set to replicate this actor is replicating on the client, what i try to do is when the client will spawn the actor i call a function who is not replicated to spawn this actor locally on the client an at the same time i run the server RPC who is creating the server side actor and then is replicated to clients. If i don’t add lag the server RPC actor and the locally spawned actor are at the same position in the world.But when i simulate lag for example 500 ms (i use clumsy who is a nice software) the client local projectile spawn directly and then after 500 ms the one who is coming from thereplicated server RPC appears and make all the server stuff (damage…)

The Question is how can i hide the replicated projectile from the owning client. I try with: DOREPLIFETIME_CONDITION(AShooterWeaponBase, CurrentProjectile, COND_SkipOwner); Don’t working then i try to hide the whole Actor but it’s hiding the Actor on all other Client to.

.h

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = “Weapon”)
FName ProjectileSocketName;

UPROPERTY(EditDefaultsOnly, Category = “Player”)
TSubclassOf ProjectileClass;

UPROPERTY(Replicated)
APhysicsProjectileBase* CurrentProjectile;

UFUNCTION(Server, Reliable, WithValidation)
void Server_FireProjectile(FVector SocketLocation, FRotator SocketRotation);

.cpp

void AShooterWeaponBase::SpawnProjectileBase() { Server_FireProjectile(WeaponMesh->GetSocketLocation(ProjectileSocketName), WeaponMesh->GetSocketRotation(ProjectileSocketName)); ClientSpawnProjectileLocally(); }

void AShooterWeaponBase::Server_FireProjectile_Implementation(FVector SocketLocation, FRotator SocketRotation) { SpawnProjectile(SocketLocation, SocketRotation); }

bool AShooterWeaponBase::Server_FireProjectile_Validate(FVector SocketLocation, FRotator SocketRotation) { return true; }

void AShooterWeaponBase::SpawnProjectile(FVector SocketLocation, FRotator SocketRotation) { if (!HasAuthority()) { Server_FireProjectile(WeaponMesh->GetSocketLocation(ProjectileSocketName), WeaponMesh->GetSocketRotation(ProjectileSocketName)); }

if (HasAuthority())
{
APawn* MyOwner = Cast(GetOwner());

 if (!MyOwner->IsLocallyControlled())
 {
     // Spawn projectile
     FActorSpawnParameters SpawnParams;

     SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
     SpawnParams.Owner = MyOwner;

     CurrentProjectile = GetWorld()->SpawnActor<APhysicsProjectileBase>(ProjectileClass, SocketLocation, SocketRotation, SpawnParams);

 }

}

}

// Not replicated void AShooterWeaponBase::ClientSpawnProjectileLocally() {

APawn* MyOwner = Cast(GetOwner());

if (MyOwner)
{
// Spawn projectile
FActorSpawnParameters SpawnParams;

 SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
 SpawnParams.Owner = MyOwner;

 APlayerController* PC = Cast<APlayerController>(MyOwner->GetController());

 if (PC)
 {
     CurrentProjectile = GetWorld()->SpawnActor<APhysicsProjectileBase>(ProjectileClass, WeaponMesh->GetSocketLocation(ProjectileSocketName), WeaponMesh->GetSocketRotation(ProjectileSocketName), SpawnParams);
 }

}

}