Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Hinge help please

Anen Graves
Registered User
Join date: 11 Mar 2007
Posts: 6
03-12-2007 21:58
Im trying to make a hinge that will rotate back and forth. Although it does rotat back and forth, each rotation moves the hinge furthr and further around the y axis. The second motion seems to double the first motion no matter what inputs I use so it progresses around and around. Here is the scroll if anyone will be kind enough to tell me what I'm doing wrong.

Thanks in advance


default
{
state_entry()
{

// a rotation of 45 degrees around the x-axis
rotation y_45 = llEuler2Rot( <0, 0, 90 * DEG_TO_RAD>;);

rotation y_b45 = llEuler2Rot( <0, 0,-90 * DEG_TO_RAD>;);

rotation new_rot = y_45 * llGetRot();

rotation bak_rot = y_b45 * llGetRot();
// compute local rotation
llSetRot(new_rot);

llSleep(.20);

llSetRot(bak_rot);
// orient the object accordingly

}

touch_start(integer total_number)
{
llSay(0, "Touched.";);
}
}
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
03-13-2007 08:24
Try something like:

CODE

rotation rot = llGetLocalRot();
rotation delta = llEuler2Rot(<0, 0, -PI/4>);
rot = delta * rot;
llSetLocalRot(rot);

llSleep(0.20)

rotation rot = llGetLocalRot();
rotation delta = llEuler2Rot(<0, 0, PI/4>);
rot = delta * rot;
llSetLocalRot(rot);


PI/4 = 45 degrees rotation
PI/2 = 90
PI = 180
TWO_PI = 360
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Simil Miles
Creator
Join date: 1 Mar 2007
Posts: 300
03-13-2007 19:47
Rather, try this working code :

CODE

default
{
touch_start(integer num_detected)
{
rotation target_rot_f = llEuler2Rot(<0, 0, -PI/4>);
rotation new_rot_f = target_rot_f * llGetLocalRot();
llSetLocalRot(new_rot_f);

llSleep(1.0);

rotation target_rot_b = llEuler2Rot(<0, 0, PI/4>);
rotation new_rot_b = target_rot_b * llGetLocalRot();
llSetLocalRot(new_rot_b);
}
}
_____________________
UnConWTech @ Flo (144, 84, 224) http://unconwtech.free.fr

SL books http://astore.amazon.com/secondlife-sl-20/

Need a beta tester for quality assurance ?
Need a translator for English, French, Spanish ?
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
03-13-2007 19:49
What...I had to put default and state_entry on it? Hehe... :p
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Simil Miles
Creator
Join date: 1 Mar 2007
Posts: 300
03-13-2007 22:38
From: Kenn Nilsson
...default and state_entry...

Well put your code in there and see what happens.
_____________________
UnConWTech @ Flo (144, 84, 224) http://unconwtech.free.fr

SL books http://astore.amazon.com/secondlife-sl-20/

Need a beta tester for quality assurance ?
Need a translator for English, French, Spanish ?