Spawning actor using python

With Blueprint, I can SpawnActorFromClass with a StaticMeshActor, but with Python script,

unreal.EditorLevelLibrary().spawn_actor_from_class(ue.Class(name='StaticMeshActor'), location, rot)

gives me:

LogPython: Error: TypeError: EditorLevelLibrary: Failed to convert parameter 'actor_class' when calling function 'EditorLevelLibrary.SpawnActorFromClass' on 'Default__EditorLevelLibrary'
LogPython: Error:   TypeError: NativizeProperty: Cannot nativize 'Class' as 'ActorClass' (ClassProperty)
LogPython: Error:     TypeError: NativizeClass: Cannot nativize 'Class' as 'Class' (allowed Class type: 'Actor')

What am I missing?

Figured this out by myself. Turns out that the .spawn_actor_from_class() call does not accept ue.Class. Instead it receives socalled ClassProperty derived from built-in types. So the correct call should be:

	unreal.EditorLevelLibrary().spawn_actor_from_class(ue.StaticMeshActor.static_class(), location, rot)
1 Like