This sounds like it would be a lot easier if you created a blueprint with a light and a mesh in it, but I’m guessing from the way you worded your post that you can’t do that for some reason.
You could try making a blueprint with two instance editable variables: One needs to be the light type you are trying to rotate (I assume a spotlight since there is no real reason to “rotate” a point light), the other should be a static mesh ACTOR variable (note, it should be the actor variable, not the component one).
-To make these variables instance editable, go to the details panel and check the box that says “Instance editable”
Then, in the construction script, get actor locations for both of the variables. Plug them into Find Look at Rotation node. Then, use the set actor rotation node and plug that into the construction script execution node, and plug the light variable in as the target and the result of the Find Look at Rotation as the desired rotation.
Then, just drag the Blueprint into the scene and go to its world editor details panel. The instance editable variables should be in the details panel with eye dropper icons next to them. Use the eye droppers to select the light and mesh you want. Then, simply move the blueprint anywhere to trigger the construction script whenever you want (by default, most blueprints trigger their construction script upon movement).
Okay, that’s the part that works out of game, if these objects are going to move in-game as well, this is continuing in another post…
I’ll preface this by saying that I’m very new to UE4 and the Blueprint interface, having come from a VFX/Motion Graphics background, so detailed answers would be much appreciated
I’m trying to figure out how to create a Blueprint that allows you to input a pre-existing Light Object (as in, one that has already been added to the World Outliner), and a pre-existing Object/StaticMeshActor (again, already in the scene), and cause the Light to always face towards the Object, even while editing the scene.
From reading around the topic I’m assuming I’d need to promote the selections in the Blueprint to be accessed as variables, and will need the ‘Find Look at Rotation’ function as detailed in this answer, but have yet to be successful in my attempts.
Additionally, (and this is perhaps due to my lack of experience with blueprints and familiarity with the tag system in C4D or modifiers/constraints in blender), I’m wondering if it’s possible to create a RectLight, for example, and then add a Blueprint to it. Or is the Blueprint the container, and the RectLight and target Object referenced within it. For example, is the workflow:
A RectLight that contains a Blueprint that selects an Object and causes the Rectlight to face towards it.
OR
A Blueprint that selects a RectLight and Object and causes the Rectlight to face the Object.
Okay, for in-game movement, go back to your blueprint and copy and paste all the code for the variables/rotation nodes into the main graph next to the “tick” node. (If there isn’t a tick node already, there, you can create one. It is the red tick node).
Then just plug all that same code into the tick.
That will make it work even if the objects move in game.
It also occurs to me that you mentioned you are motion graphics. Are you by any chance trying to use sequencer? If that is the case, you may also want to go to the blueprint and in the class settings select that the construction script will also work in sequencer.
Wow, thanks for such a detailed answer and additional info Detach! In the end I decided that it would be best to go down the route of your original suggestion by creating a blueprint with a rect light contained within it, as I didn’t realise that the blueprint would only update in the editor if you move it (it was getting frustrating to move the rectlight, and then select and wiggle the BP actor to get the light angle to update) Here’s a screenshot of my setup for any future visitors to the post: