How do i change the intensity of an existing spotlight in c++?

I have placed some spotlights in my map, and I am trying to figure out how set up a pointer to them in C++ so I can vary the intensity, colour etc. at different times. Is this possible and how can I go about this? I have followed a couple of tutorials but they create they create the object in the code itself which I do not wish to do.

If you don’t want to create the objects in code there are 2 ways you could go about it.

  1. Make a new actor type with a property that is an array of lights you would like to manipulate in code. Put it in your level then add all the lights you want to manipulate into it’s array in the editor. Now they will be accesible from code.

  2. If you don’t want to make a new actor you can query the world for all lights. Something like the following snippet :

    for (TActorIterator ActorItr(GetWorld()); ActorItr; ++ActorItr)
    // Do stuff with a spotlight

You can read more on actor iterators and object queries here :

A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine ForumsObject%26_Actor_Iterators,_Optional_Class_Scope_For_Faster_Search

Make sure you add a UPROPERTY(EditAnywhere) above the definition of the TArray LightRefs; Otherwise the array won’t show up in the editor