Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Locking X and Y axes

Alicia Mounier
Registered User
Join date: 17 Oct 2005
Posts: 78
08-02-2007 03:32
I'm trying to lock the x and y axes on a child prim, it's for a turret body on a tank but seems lllSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE) is not working like i thought it would,can someone help me out here and show me how to do this? right now i use llsetrot along with a sensor to make it move.

sensor(integer sense)
{
llSetRot(<STATUS_ROTATE_X,STATUS_ROTATE_Y,((llDetectedRot(0) / llGetRootRotation()) / llGetRootRotation())>;);
}

Thanks!!!!!!! look, no lols! nvm :eek:
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
08-02-2007 10:39
So many issues.. not sure where to begin...

1) llSetStatus only applies to physical objects.
2) llSetStatus only applies to the whole object, not child prims (in a physical object, child prims are not independent).
3) Using the constants STATUS_ROTATE_X, etc as values in a vector is nonsensical.
4) llSetRot takes a rotation, not a vector.
5) Unless the turret is a single prim, llSetRot/llSetLocalRot will only rotate the single child prim it is in, not the whole turret.
Alicia Mounier
Registered User
Join date: 17 Oct 2005
Posts: 78
08-02-2007 13:21
lol, ignore that llSetRot(<STATUS_ROTATE_X,STATUS_ROTATE_Y,((llDetectedRot(0) / llGetRootRotation()) / llGetRootRotation())>;); it was supossed to be something else i was just trying some stuff out to see what would happen. it should be llSetRot(<0.0, 0.0, 0.0, 0.0> * ((llDetectedRot(0) / llGetRootRotation()) / llGetRootRotation()));. however as you said it is child prim like what i need it for, basicaly i have two things that need to move around, the barrel and then the turret body that it looks like it is on, all of this is attached to the vehicle that is phys to move. the barrel looks fine but i dunno how to make the turret just spin along with the barrel it wants to look up and such. i was half asleep when i posted this earlier so i dunno how i messed up and got that messed up looking string in there. Anyways thanks for the reply.
Ed Gobo
ed44's alt
Join date: 20 Jun 2006
Posts: 220
08-03-2007 04:14
I think quaternians need internal consistency and all zeroes does not work that way in a quaternian.

Suggest you start with a vector with angles you understand in degrees, multiply by a factor to make radians, then convert to a rotation, using the relevant LSL calls.

The reverse is discussed here"
http://wiki.secondlife.com/wiki/Rotation
Alicia Mounier
Registered User
Join date: 17 Oct 2005
Posts: 78
08-03-2007 15:13
I suck at math but thanks anyways, I'll keep reading in the wiki about rotations when i can get some time off of work and such. i currently use llSetRot(((llDetectedRot(0) / llGetRootRotation()) / llGetRootRotation())); cause the whole <0.0,0.0,0.0> doesn't let it do anything. :D Whenever i get an update I'll post it here so other know what to do when they are tring to make something that uses your mouselook or something to make an item rotate and you want to lock a certain axis say like a turret body.
Alicia Mounier
Registered User
Join date: 17 Oct 2005
Posts: 78
08-05-2007 19:24
i'm bumping this!!!! currently i am using this and it works but i dunno how to make it where x and y don't move and don't tell me something like you need to null this and that cause I don't know how. Please Help!!!!!!! I'm at the end of my skills for this stuff. :confused:

CODE

sensor(integer sense)// got a sensor running and it does stuffs to track things.
{
llSetLocalRot(((llDetectedRot(0) / llGetRootRotation()) / llGetRootRotation()));
}


:D
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
08-05-2007 21:55
You just want it to turn to the direction the target is facing, yes?

This isn't fancy math becasue I don't do fancy math, but it works okies by and large (with some obvious problems with precision).

sensor(integer n)
{
vector offset = llRot2Fwd(llDetectedRot(0));
offset.z = 0;
vector my_pos = llGetPos();
vector targ_pos = my_pos + offset;
rotation target = llRotBetween(<1, 0, 0>, (targ_pos - my_pos));
llSetLocalRot(target / llGetRootRotation());
}
Alicia Mounier
Registered User
Join date: 17 Oct 2005
Posts: 78
08-06-2007 00:54
Sweet! it works just fine even if it isn't fancy math. and yes i just wanted it to face the right direction rather then actualy look up and down.