View Full Version : Rotate light to point at object

08 August 2005, 11:09 AM

What is the best way to orient a light towardsthe centre of a given object?
Can I load a variable using aimConstraint,or is it better to use xform in some way and get a vector to that xform and apply that to the lights rotation.
I`m just early learning of mel so I`m trying to figure the best way to go about things.

Thanks for any help given.


08 August 2005, 11:26 AM
I think the fastest way to go is using the aim constraint. It does all the math calculations for you, you just use it's output rotation. The method of using it also depends of where do you need that. If you were doing a once execution commad, you could constrain the light and delete the constraint. In case if you'd have a loop for many lights, constraining/deleting can really drop the performance of the script. In this case it's suggested to create one aim constraint node, then in the loop you just set new aim position/read output rotation and set it to the light. In the end of the loop you can delete your constraint:)


CGTalk Moderation
08 August 2005, 11:26 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.