Download

How to create a placeable actor that you can assign a static mesh in the editor?

I’m trying to create my own actor that is placeable in the editor. And i’d like to allow it to be dynamically assigned a static mesh actor in the editor.

How would i do this? Here’s what i have:



class MyFluidSurfaceActor_River extends Actor
placeable;

var StaticMeshComponent RiverMesh;

defaultproperties
{    
    Begin Object class=StaticMeshComponent Name=StaticMeshComp
        StaticMesh=StaticMesh'ColdItems.StaticMeshes.crate' //Placeholder
    End Object
    RiverMesh=StaticMeshComp
    Components.Add(StaticMeshComp)
}


In this case i’d like to assign the static mesh in the StaticMeshComp within the editor (so i can reuse this actor with lots of different meshes).

Any help would be much appreciated.

Thanks

var() StaticMeshComponent RiverMesh; ?

class PBMainActor extends Actor
ClassGroup(PBSkeletalMeshes)
placeable;

Make the ClassGroup(ColdsStaticMeshes) or any name you like. then go into editor and you’ll see it there under your new name



class MyFluidSurfaceActor_River extends Actor
ClassGroup(ColdsStaticMeshes)
placeable;

var StaticMeshComponent RiverMesh;
var() StaticMesh ColdsModel;//this will allow you to hit f4 and add in what ever model you want,
once you've added MyFluidSurfaceActor_River to your map

function PostBeginPlay()
{
  local bool AreWeMade;

  AreWeMade = RiverMesh.SetStaticMesh(ColdsModel);
     `log("MyFluidSurfaceActor_River::PostBeginPlay() Has Started up!, Is the test MyFluidSurfaceActor_River Running = " @ AreWeMade);
} 

defaultproperties
{
    Begin Object class=StaticMeshComponent Name=StaticMeshComp
           StaticMesh=StaticMesh'ColdItems.StaticMeshes.crate' //Placeholder
    End Object
    RiverMesh=StaticMeshComp
    Components.Add(StaticMeshComp)
}


that should get what you want working; enjoy.

Awesome, that worked perfectly. Thank for the help guys :wink: