import unreal
def spawnActor1():
actor_class = unreal.EditorAssetLibrary.load_blueprint_class("/Game/BpActor")
actor_location = unreal.Vector(0.0, 0.0, 0.0)
actor_rotation = unreal.Rotator(0.0, 0.0, 0.0)
unreal.EditorLevelLibrary.spawn_actor_from_class(actor_class, actor_location, actor_rotation)
def SpawnActor2():
world = unreal.EditorLevelLibrary.get_editor_world()
# 这个地方要注意,要加一个world ,这个world 代表上下文环境
actor_object = unreal.load_object(world, '/Game/BpActor')
actor_location = unreal.Vector(0.0, 0.0, 0.0)
actor_rotation = unreal.Rotator(0.0, 0.0, 0.0)
actor_scale = unreal.Vector(3.0, 3.0, 3.0)
actor = unreal.EditorLevelLibrary.spawn_actor_from_object(actor_object, actor_location, actor_rotation)
actor_tags = actor.get_editor_property('tags')
actor_tags.append('My Python Tag')
actor.set_editor_property('tags', actor_tags)
actor.set_actor_scale3d(actor_scale)
UE4_Python 在场景中 Spawn Actor
最新推荐文章于 2023-03-01 16:13:30 发布