I am attempting to create a script which will create a row of boxes, going from one point to another(both chosen objects).
The (first) attachment shows what I have at the moment, and the second(manually rotated) shows what I'm trying to get(the reason the boxes aren't inbetween the two boxes, but offset is because the pivot is still in the center, not at the end).
I have managed to get the positions correct, but haven't been able to get proper rotations.
Any help would be appreciated, I have been trying for a while, and havent managed to get a properly working result.
Edit:
I have also tried using a look at constraint, but haven't been able to transfer the objects rotation to the others, and I don't want to add the constraint to every box.
Forum topic · General Scripting
Aligning boxes rotation to face a object
By brttd · 2013-02-19
Downloads
- problem2.png — problem2.png19 KB
- problem1.png — problem1.png17 KB
Description
Comments (2)
Swordslayer · 2013-02-19
Something like this would be a way, of course this is just one of many solutions and probably the most stupid one, but good as a starting point nonetheless.
fn rotateBox b p1 p2 =
(
local x = normalize (p2.pos - p1.pos)
local y = cross z_axis x
local z = cross x y
b.transform = matrix3 x y z b.pos
)
rotateBox $Box001 $Point001 $Point002
brttd · 2013-02-20
Thanks! It works well (only had to change round the x & y(the boxes were overlapping)), Im not that knowledgeable with stuff like this so thanks again.