Spawning a light via Python

Hello,

I’m trying to create a python script to spawn a directional light in the scene. Currently this is what I have:



sun_class = unreal.DirectionalLight(outer=None, name='Sun')
sun_location = unreal.Vector(0.0, 0.0, 500.0)
sun_rotation = unreal.Vector(0.0, 0.0, 0.0)
unreal.EditorLevelLibrary.spawn_actor_from_class(sun_class, sun_location, sun_rotation) 

But I can not have "outer’ to equal ‘none’. What do I need to replace this argument with to satisfy it?

Here is the API source I referenced:
https://docs.unrealengine.com/en-US/…onalLight.html

UPDATE:
I’ve resolved this issue by changing to
unreal.EditorLevelLibrary.spawn_actor_from_object

1 Like

This works for “spawn_actor_from_class”



sun_location = unreal.Vector(0.0, 0.0, 500.0)
lightObj = unreal.EditorLevelLibrary.spawn_actor_from_class(unreal.DirectionalLight, sun_location, rotation=[0,0,0])
lightObj.set_actor_label("sun")