Announcement

Collapse
No announcement yet.

Switch between static and skeletal mesh in a blueprint at runtime

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Switch between static and skeletal mesh in a blueprint at runtime

    I have a generic BP_Pickup blueprint. I have a lot of functionality I would like to inherit into sub classes - e.g. BP_Pistol or BP_Ammo. But pistol has a skeletal mesh and Ammo has a static mesh. My current solution is that there is both in the BP_Pickup, and I use a bool to decide which to hide/show or interact with during run time. It is also possible that selected instances have both, and I switch from skeletal to static to save performance when animations on a mesh are no longer necessary, for example switching a static mesh of a complicated weapon to static when it is disabled and lying on the floor.

    Other than the hundreds of warnings about one of the static or skeletal meshes have no mesh allocated, I'm sure this is not the most performant method. I was thinking of just using a MeshComponent which appears to be a parent to both, and then casting to either static or skeletal during runtime - I'm just not sure this is the right way, or will work as expected.

    If anyone has solved this - pls let me know.

    #2
    Either do this in C++, where you can have UPrimitiveComponent (both SkeletalMeshComponent and StaticMeshComponent inherit from it) or you could convert your Pistol/SkeletalMesh to a Static Mesh.

    I do exactly this. My Pistol on the Character is a SkeletalMesh, while the Pickup and Inventory Mesh is a static Mesh because it isn't animated there.

    Comment


      #3
      Thanks - sounds like the strategy is then to reparent my top level blueprint (BP_Interactable, from which everything inherits) to a new C++ class (say CPP_Interactable) which inherits from AActor and has a UPrimitiveComponent - then all my other BP's just need to be updated, but can largely remain unchanged.

      Comment

      Working...
      X