I wanted to setup some portrait lights the way I’m used to doing it in Blender and DAZ Studio. In those apps, we usually have a way to point a light source at an object so that when we move either of them around, the other one follows. The above GIF is a good example of how I like to adjust my light and preview the effect. By default there’s no such option in Unreal Engine editor.
There is a way to make use of the Look At Rotation between two objects, from which we can then set a new world rotation. While this works great in a running game, it does not work in the Editor as we have to Tick event that could be used to update this as we move either object. The trick is to make use of the Editor Tick event I’ve written about earlier, then hook this mechanism and get the effect we’re looking for. Let me show you how it’s done.
The Tracking Magic
Here’s what my running Spot Light Blueprint looks like (click to enlarge). It’s a sequence with two paths: the top one grabs a reference to the object we want to track, in my case a simple Target Point. We do this only once and store a reference for performance reasons, but it’s less important in the editor than it would be in a shipped game.
The bottom part grabs the World Location of both the Spot Light and the Tracking Point (or more precisely, the respective components inside those nodes), then we find the Look At rotation of both objects. Make sure the target is the tracking point, and the source is the Spot Light. Now we set a new World Rotation on the Spot Light so that it moves continuously.
I’ve split this out as a function that needs to be executed on my home-made Editor Tick, which I’ve explained in a previous article.
That’s it! Not super straightforward, but also not impossible to do. Makes you appreciate how much casual code is going on under the hood of the regular 3D apps we know and love.
Demo Project
If you want to try this project out and dissect it, be my guest – I have a GitHub Repository for you: