Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Quick question: rotating to face a point

Winston Lagerlof
Registered User
Join date: 13 Jan 2006
Posts: 11
01-31-2006 12:43
I know this shouldn't be difficult, but I've been looking at functions and thinking about it for a few hours now and still don't have it. I have two vectors as points in space in the same XY plane (basically, both on the ground). I have an object at one point that I want to rotate around its Z to face the other point. What's the easiest way to do this?
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
01-31-2006 13:08
http://secondlife.com/badgeo/wakka.php?wakka=llRotLookAt
Zepp Zaftig
Unregistered Abuser
Join date: 20 Mar 2005
Posts: 470
01-31-2006 13:17
Ehh, I think what I wrote first could work, I dunno I'm a bit tired and I can't test it right now and I managed to delete that text.
Winston Lagerlof
Registered User
Join date: 13 Jan 2006
Posts: 11
01-31-2006 13:23
I'll try that out. I was hung up on llRotLookAt, the wiki says it requires a rotation:

llRotLookAt(rotation target, float strength, float damping);

So I was trying to figure out how to derive that rotation from two points.
Zepp Zaftig
Unregistered Abuser
Join date: 20 Mar 2005
Posts: 470
01-31-2006 13:34
Actually I guess you could just use llLookAt(vector target, float strength, float damping).
Winston Lagerlof
Registered User
Join date: 13 Jan 2006
Posts: 11
01-31-2006 13:39
Damn, I keep missing functions that would make life a whole lot easier. Except that points Z at the target, so I'll have to do some messing. Thanks, though.
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
01-31-2006 13:42
Oops. Sorry. Meant to paste the link for llLookAt. There's a sample script in there that shows you how to point an axis other than the Z axis to the desired location.
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
01-31-2006 14:39
llRotLookAt(llRotBetween(<1, 0, 0>, vectorTarget - llGetPos()), 0.25);

or directly:

llSetRot(llRotBetween(<1, 0, 0>, vectorTarget - llGetPos()));
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Winston Lagerlof
Registered User
Join date: 13 Jan 2006
Posts: 11
01-31-2006 14:43
That's alright, I put in the wiki's example and it's all working like a charm. Thanks!

Hey, in case anybody sees this, I have one other question: suppose I want a physical object to vertically attract like a vehicle. I haven't messed much with vehicles at all, but would it work just to set the main vehicle flag and turn on the vertical attract? It wouldn't mess anything else up like people being able to drive it or anything?