Download

Python - Renaming Object On Spawn

I have a sun light that spawns and it works great. But it defaults to the name “DirectionalLight”. How can I change this spawn naming at runtime? This is my current function:



def spawn_sun():
    sun_class = ue.DirectionalLight()
    sun_location = ue.Vector(0.0, 0.0, 500.0)
    sun_rotation = ue.Rotator(0.0, 0.0, 0.0)
    ue.EditorLevelLibrary.spawn_actor_from_object(sun_class, sun_location, sun_rotation)




lightObj = ue.EditorLevelLibrary.spawn_actor_from_object(sun_class, sun_location, sun_rotation)
lightObj.set_actor_label("sun")


Thanks Squirrel2, that works!