Setting default mesh to a class property
I want to create a tile-based map of a given size (like 8*8 tiles) from a given Tile (square or hexagonal). I plan to store this default mesh in a class property: UPROPERTY(EditDefaultOnly, Category = "Default Mesh") UStaticMesh * TileMesh; But the problem is that a don't know how to properly initialize this property (in c++ class) from an exist mesh in my project. I've tried CreateDeafaultSubobject(), static ConstructorHelpers::FObjectFinder MyMesh(TEXT(%mesh reference%)), but it is always NULL on game start. How can i set default mesh to my class property?
asked Apr 16 '15 at 08:04 AM in C++ Programming
If you want to use your method of exposing it as a class property, like so :
Than, you need to create a Blueprint in the editor with your class. In this blueprint, in the Class Defaults section, you will have your property show up there so you can select a Static Mesh from those you have imported in your game.
Otherwise, you can use the object finder to automatically load the mesh in your class constructor like so :
Of course this is only the static mesh, to actually use it you need to assign it to a StaticMeshComponent, but I guess you already know that?
Hope this helps!
answered Apr 16 '15 at 11:28 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here