Hi,
I am trying to get a portable spotlight on a character. When the character rotates, the light keeps pointing in the same direction.
How can I keep the light always pointing in the same direction even when the character moves around and rotates?
For example, if the character faces -X the light is on his face, if the character faces X the light is on his nape. If the character faces Y the light is on the right side of his face. And if the character moves, the light moves along with him.
Have you tried making the spotlight a child of the character? In the BluePrint Editor where you add components, drag and drop it onto the piece you want the spotlight to move with, before you release it should say something like “attach to” with a green checkmark. When you do that, it should keep the same rotation as the component it is assigned to as it moves around, without coding its individual movement.
If you want the light to be attached to the character and move with them, make the light a child of the character, and use “relative” rotation mode.
If you want the light to be attached to the character, but NOT rotate with the character, make the light a child of the character, and use “global” rotation mode.
Thanks for the suggestion! It works, kind of.
As a child it does move with the character and “World” rotation keeps it pointing towards the same world direction.
Now the issue is that somehow the character runs around the light instead of the light staying on the left side of the character. How can I make the light stay on the left and prevent it from moving up and down as shown in the GIF in dropbox.
You probably have “inherit control rotation” on. This makes the character rotate the same way that the player controller does.
You could try turning it on only for heading, not for pitch or roll.
Unfortunately, if you want the camera to rotate with the controller, but the light not, then you will need to add some logic to the character that updates the camera boom rotation based on the input control rotation, without affecting the light object or the character object.