Hello everyone, I’m trying to create a python function that will spawn an actor into the world, but I can’t set the scale for it. Unreal 4.27 does not support unreal.GameplayStatics.begin_spawning_actor_from_class and unreal.GameplayStatics.finish_spawning_actor which took a transform. Instead, unreal.EditorLevelLibrary.spawn_actor_from_object is left which only accepts translation and rotation.
Set scale after spawn with unreal.Actor.set_actor_scale3d? But I don’t know how to refer to a specific actor after creation (I’m new to the unreal python api). Here is my code at the moment:
def assetspawn(name, translatex, translatey, translatez, rotatex, rotatey, rotatez, scalex, scaley, scalez):
# world = unreal.EditorLevelLibrary.get_editor_world()
AssetPath = return_asset(name)
actor = unreal.load_asset(AssetPath + "." + name)
actor_translate = unreal.Vector(translatex, translatey, translatez)
actor_rotate = unreal.Rotator(rotatex, rotatey, rotatez)
actor_scale = unreal.Vector(scalex, scaley, scalez)
# actor_transform = unreal.Transform(actor_translate, actor_rotate, actor_scale)
actor_before_scale = unreal.EditorLevelLibrary.spawn_actor_from_object(actor, actor_translate, actor_rotate)
unreal.Actor.set_actor_scale3d(actor_scale)
#spawned_asset = unreal.GameplayStatics.begin_spawning_actor_from_class(world, actor, actor_transform)
#unreal.GameplayStatics.finish_spawning_actor(actor, actor_transform)
# unreal.EditorLevelLibrary().spawn_actor_from_class(ue.StaticMeshActor.static_class(), location, rot)
# world = unreal.EditorLevelLibrary.get_editor_world()
# _class =unreal.EditorAssetLibrary.load_asset('/GameMiddles/Base/SM_Base_B_OUT')
# location = unreal.Vector(0, 0, 0)
# rotation = unreal.Rotator(0, 0, 0)
# scale = unreal.Vector(1, 1, 1)
# transform = unreal.Transform(location, rotation, scale)
# # begin spawn
# actor = unreal.GameplayStatics.begin_spawning_actor_from_class(world, _class, transform)
# unreal.GameplayStatics.finish_spawning_actor(actor, transform)