Changing spotlight position.

Trying to understand how to transform a Spotlight to a certain position without its rotation angle being reset. Currently when I use a transform on the spotlight it's angle goes back to 0,0,0 before going to the transform rotation.
Answered by Vision Pro Engineer in 615282022
A SpotLightComponent shines in the forward direction of the entity's Transform. A good way of setting the spot light's position and the target's position at the same time is the look(at:from:) function. If you don't want to change the direction of the spot light, but you do want to move it to a new origin, you can change the position property of the entity.

Note that changing the position leaves the orientation of the light unchanged, so the light will end up "looking at" a different place.

Does that help? If you need more clarification, it may be helpful to post a code snippet.
Accepted Answer
A SpotLightComponent shines in the forward direction of the entity's Transform. A good way of setting the spot light's position and the target's position at the same time is the look(at:from:) function. If you don't want to change the direction of the spot light, but you do want to move it to a new origin, you can change the position property of the entity.

Note that changing the position leaves the orientation of the light unchanged, so the light will end up "looking at" a different place.

Does that help? If you need more clarification, it may be helpful to post a code snippet.
Changing spotlight position.
 
 
Q