This content has been marked as final. Show 1 reply
(After typing this up in notepad, I accidentally posted it in response to your crane question instead of this thread!)
To align a model to a vector (such as your ray cast vector), you can use something like this:
tiltAngle = vector(0,0,1).anglebetween(theVector)
tiltVector = theVector.perpendicularto(vector(0,0,1))
theModel.transform.rotation = vector(0,0,0)
To align it to a ray vector, and display it correctly, if your model was a 'box' from director's default box primitive, you would then want to position it halfway between the ray cast source, and the ray intersect position (because the box's origin is in its centre), and scale it so that it extends the full distance between the two.
Luckily this is actually a frequently asked question, and something that I do quite a lot myself - so I happen to have some demo movies showing it in action!
First here's some roughly compiled information about modelsUnderRay(), mostly advice I've given out on various director mailing lists in the past:
And here are a few demos of how it can be used effectively (including one with visible beams as you described!)