Hello there.
I’m trying to use the Python plugin to automate some content creation. Specifically, I am trying to create an actor with a HierarchicalInstancedStaticMeshComponent and place it in a scene, without resorting to blueprints.
I’ve been trying this for a while now and haven’t quite figured out the way yet. Here is how far I’ve got:
- Create actor: "ac = unreal.EditorLevelLibrary.spawn_actor_from_class(unreal.Actor, unreal.Vector())
- Create my static mesh: "■■■ = unreal.EditorAssetLibrary.load_asset(‘/Game/foo/bar’)
- Create my component: "c = unreal.HierarchicalInstancedStaticMeshComponent(ac, ‘mycomponent’)
Notice above that I am forced to provide an “outer” to the component. I just picked “ac” (my actor) but that feels incorrect. a ‘None’ is not accepted. What is the correct way to create the component?
- Assign the mesh to the component: c.set_static_mesh(acc)
Now comes the problematic part. I’d like to set the component as the actor’s root component. But if I do:
“ac.set_editor_property("root_component", c)
”
then the component shows up, but it is flagged as (inherited) in the level editor, and I cannot edit it. The editor displays a warning that it needs to be a UProperty to be editable, or something like that.
If I attach it to the root component, by:
c.attach_to_component(ac.root_component, "", unreal.AttachmentRule.KEEP_RELATIVE, unreal.AttachmentRule.KEEP_RELATIVE, unreal.AttachmentRule.KEEP_RELATIVE, False)
Then it doesn’t show up. Additionally, I start to get errors like:
LogPython: Error: Exception: Actor: Internal Error - ObjectInstance is null!
So: What is the correct way to a) create the component without having an “outer” and
b) attaching it as the root component to an Actor?