I was wondering if there are any performance differences between directly spawning a Static Mesh and spawning an Actor that represents that Static Mesh?
I aim to generate meshes procedurally and randomly, and creating an actor would offer more functional benefits. However, I don’t want to compromise performance. If it’s necessary, I prefer sacrificing these functional benefits for significant performance gains. Otherwise, I would prefer to spawn an Actor.
Does anyone have any insights or clarification on this matter?
Hey @3dRaven thanks for your answer. But what about creating a static mesh onto an actor directly?
For example, I am making an inventory system where I don’t want to spawn actors and attach to my character all the time. So, if I wish to wear a helmet or armour, equip a shield or wear boots, I was thinking if I could add a static mesh component to my actor dynamically. And then set the static mesh with that relevant asset - spartan_helmet, golden_armour, elven_boots etc.
Of course, in a multiplayer setting, this should be a NetMulticast RPC if I’m not wrong.
So, what is your advice?
Do you think I should spawn an actor that replicates, and on RepNotify - change the static mesh of that item for all clients to that static mesh asset?
Or spawn static mesh components attached to my character’s skeletal socket - with NetMulticast?
I do wish to bind overlap events for certain static meshes, like a sword / axe / spear - there’s that requirement too!
For equipment on the character you should have skeletal mesh component that match your character skeleton and use the leader pose to drive the mixed meshes as 1 character combination.
You should set the skeletal mesh component’s mesh via on rep notify so that it updates even for people that later join your game.
Only part where static meshes would be useful is if the clothes / armour doesn’t deform at all. Though it’s extra overhead in that you need extra functions to handle the attachment to a specific bone.
This is a tough task when it comes to body armour as you may get the underlying clothing to clip through the armour at angles.(it’s more a rigging problem though than an unreal one)
To further the optimizations you could combine the skeletal meshes into a new one at runtime, but that would probably require more work.
Alright, will look into Skeletal Mesh merge, that could help me.
Yeah, RepNotify on mesh components could be a great place to render the right static mesh.
How are functions to attach to a specific bone an overhead? Isn’t it always done that way - Spawn Actor and Attach to socket?
(Or for some items in my game, create static mesh at SkeletalMesh-socket, and then update mesh in ReNotify)?