Hello, I’ve hit a bit of a wall when trying to implement a character which changes skeletalmesh on the press of a button, so I figured I would try to ask here! I’ve so far modified the shootergame code as a base.
So far I’ve made it work by having several SkeletalMeshComponents and making them invisible/visible depending on the conditions I’ve set and while it seems wasteful to have all those components just lying around waiting to be used it works for now, clientside anyway.
The problem is that any meshcomponent apart from the original one does not replicate properly to other clients, showing up even though it’s supposed to be invisible, does not animate to other players and/or crashes.
So what I’d like Is to either:
- Is there a way to change the character’s mesh in code (or in blueprints, so long as it replicates to all other players. I’ve seen that there are some problems with replicated blueprints) while pointing to an object in the asset browser? Or perhaps a similar way.
That way I wouldn’t have to have multiple skeletalmeshcomponents lying around, toggling their visibility when required, but rather only change the mesh in the code when required to do so. If possible, could you write a very basic way to do so within a function? I noticed there was a Mesh->SetSkeletalMesh function, but I was unsure of how to use it properly.
2 If not possible, what is the requirements for making a skeletalmesh replicatable? My declaration for one of the meshes is as follows:
UPROPERTY(VisibleDefaultsOnly, Replicated, Category = Mesh)
I added the Replicated part in the character header and in the cpp I added
DOREPLIFETIME_CONDITION(AShooterCharacter, MeshFire, COND_SkipOwner);
Toward the bottom. I tried without a condition but then it crashed due to the mesh being Null when the second player spawns for some reason. Maybe there’s an underlying problem if the replication is in fact correct?
Either way, solving the first problem would probably be easiest and best in this case, hopefully someone out there can enlighten me!