Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation Question

Angus Balboa
Registered User
Join date: 19 Aug 2006
Posts: 14
11-19-2007 15:15
I'm currently using llLookAt for my object to look at its owner... however, since it's stationed on the ground, I want only the Z axis to rotate and face the owner, rather than y and x also. How can I accomplish that?
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-19-2007 19:09
From: Angus Balboa
I'm currently using llLookAt for my object to look at its owner... however, since it's stationed on the ground, I want only the Z axis to rotate and face the owner, rather than y and x also. How can I accomplish that?


Not sure of the code you are using but llLookAt will point the Z axis at the target instead of rotating to Z axis. You can specify a different axis to use but you are still going to be swivelling on the other two axis to achieve that;

The old wiki shows how to use a different axis:

http://www.cheesefactory.us/lslwm/llLookAt.htm

Thinking about it some. What about using llSetStatus(STATUS_ROTATE_?, FALSE)
Which will keep that axis from rotating. You can set more then one axis to FALSE.

http://www.cheesefactory.us/lslwm/llSetStatus.htm

Let me know if this doesn't help
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Angus Balboa
Registered User
Join date: 19 Aug 2006
Posts: 14
11-19-2007 19:30
Alright I'll try that. Thanks.
Angus Balboa
Registered User
Join date: 19 Aug 2006
Posts: 14
11-19-2007 20:00
Ok as you mentioned, llLookAt doesn't actually rotate it, so setting the status doesn't work with it... so I'm thinking llRotLookAt is what I need for it to work, except the variable it's using is a rotation rather than a position.

So what exactly do I use now? I tried llRotLookAt(llDetectedRot(0), .35, .03); but that just makes it face the same direction as the owner rather than facing towards the owner.
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
11-19-2007 20:10
llSetRot(llRotBetween(<0.0, 0.0, 1.0>, (llDetectedPos(0) - llGetPos())))
_____________________
Angus Balboa
Registered User
Join date: 19 Aug 2006
Posts: 14
11-19-2007 20:19
llSetRot seems to ignore the status changes I made for the rotation axes... I even set all three to false, and it still rotated every angle.
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
11-19-2007 20:21
From: Angus Balboa
llSetRot seems to ignore the status changes I made for the rotation axes... I even set all three to false, and it still rotated every angle.

\(?_?)/
_____________________
Angus Balboa
Registered User
Join date: 19 Aug 2006
Posts: 14
11-19-2007 20:28
Actually scratch that... I realized what you just gave me works without turning off the rotation status; however, the axis it's rotating on seems to be off... it's rotating in a weird way, which is why I thought there was a conflict. I think it might have something to do with the fact that I have multiple objects linked together, but that doesn't explain why manual rotation works like it's supposed to... :/
Angus Balboa
Registered User
Join date: 19 Aug 2006
Posts: 14
11-19-2007 20:31
The best way I can explain it is this... head on, it faces me almsot right, but then when I walk past it (now I'm on the opposite side) it's still facing me, but is now upside-down
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
11-19-2007 20:34
Manual rotation (with the build editor) rotates the object around the center of mass (or the geometric center, hard to tell). llSetRot llLookAt, etc rotate the whole object around the center of the root prim.

STATUS_ settings should have no effect unless the object is physical, which llSetRot won't work if it is.
Angus Balboa
Registered User
Join date: 19 Aug 2006
Posts: 14
11-19-2007 20:38
Would applying an offset work then? And if so, how would I do that with llSetRot?
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
11-19-2007 20:46
Well, if you can't move the root prim to the center of the rotation you want, you can use the function described here to perform an offset rotation.
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
11-19-2007 21:05
The problem is that you want 'upright' rotation, meaning some face of the object should be pointing upward while some other face is pointing 'forward' at you.

vector fwd = llVecNorm(llDetectedPos(0) - llGetPos());
vector left = <0.0, 0.0, 1.0> % fwd;
rotation upright = llRotBetween(<1.0, 0.0, 0.0>, <0.0, 0.0, 1.0>;) * llAxes2Rot(fwd, left, fwd % left);
llSetRot(upright);

This works assuming your 'pointing' axis is the object's positive z axis.. I think. Not logged in, test it yourself. Assuming it works, you can adjust it so that the any arbitrary 'pointing' axis vector is defined by the second parameter in the llRotBetween call. The 'upright' facing part of the object is automatically a characteristic of how it's built in relation to its 'pointing' axis.

Edit: Tested in-world, durf durf, changed a little.
_____________________
Angus Balboa
Registered User
Join date: 19 Aug 2006
Posts: 14
11-20-2007 13:42
Well I tested it out by putting it in a cone, and walking around it and jumping, and it follows me at every angle. Your explanation seems like what I want, but for some reason it's just not working for me. Am I doing something wrong? I tried changing the vectors some, but that just made it worse or did nothing... lol. Unfortunately I think my comprehension level in this area is very poor. :/

Just for clarification, imagine an animal facing something; llLookAt would be a good effect for the head, which would be able to look in all directions, but its body would only face what it's looking at, on one axis (which I'm assuming would be Z). This is the effect I'm trying for.