I have problems getting to work the detaching of an static mesh for network mode.
I spawn an actor, which is basically a StaticMesh in network mode, gets replicated correctly.
The problem happens when detaching the static mesh. If the involved actors are relevant the system works ok, but if one of the actor becomes irrelevant and return the the area where a detach action happened, an artifact of the static mesh remains in the world.
I am not sure if this is related to the way I am destroying the StaticMesh or I need another network mechanism to handle the situation. But anyways the static mesh was destroyed and there is no reference to keep for it.
I spawn the static mesh with the SpawnActor and attach to mycharacter .
AMyActor* MyActor = Cast<AMyActor>(GetWorld()->SpawnActor(MyStaticMeshClass, &PlayerLoc)); MyActor->MyStaticMesh->AttachTo(MyCharacter->GetMesh(), MySocket, EAttachLocation::SnapToTarget);
Later when I remove this actor,
I tried calling other methods, previous to the destroy just for testing
DetachFromParent DestroyComponent ConditionalBeginDestroy
But all ended up with the same artifact problem.
For the SpawnActor part, I also tried adding FActorSpawnParameters so that the parent of the object is explicit, but I didn’t make any difference.
Perhaps I should Destroy the actor through the Owner???
Please, give me your advice on how to properly destroy it or what the missing piece.
NOTICE: the actor is actually detached and destroyed for the own player and the others. The only problem is for the others, where the static mesh artifact remains in the world.