Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Positioning things perpendicular to the ground.

Miriel Enfield
Prim Junkie
Join date: 12 Dec 2005
Posts: 389
10-17-2008 00:49
I want to script some cubes to automatically rotate themselves so that they're perpendicular to the ground. I'm assuming that llGroundNormal() is the best thing to use, but my knowledge of vector math is really lacking, and I'm not sure how to convert llGroundNormal()'s results into something llSetRot() can use. Can anyone help?
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
10-17-2008 04:22
Some skilled geometer should have a better or more complete answer, but if an answer is urgently needed, I would think that llAxes2Rot() should be able to do this, with a little experimentation.
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
10-17-2008 07:03
There's probably loads of ways to calculate it, but here's a single-line solution:

CODE

llSetRot(llRotBetween(<0.0, 0.0, 1.0>, llGroundNormal(<0.0, 0.0, 0.0>)));


It works pretty simply by calculating the rotation between global 'up' and the ground's normal, and then applying it as the object's rotation.
Miriel Enfield
Prim Junkie
Join date: 12 Dec 2005
Posts: 389
10-17-2008 07:05
That works perfectly, Pedro. Thank you!