|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
01-11-2009 18:07
this has been bugging me i cant figure it out, when i fire something it always points east as rezed im trying to make it point whatever way im looking anyone have any ideas?
vector pos; rotation rot; vector offset;
float BULLET_VELOCITY = 30.0; float REPEAT_DELAY = 0.15;
default { run_time_permissions(integer perm) { if (perm) { llAttachToAvatar(ATTACH_LHAND); llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE); } } attach(key on) { if (on != NULL_KEY) { integer perm = llGetPermissions(); if (perm != (PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH)) { llRequestPermissions(on, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH); } else { llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE); } } else { llTakeControls(FALSE, TRUE, FALSE); } } control(key owner, integer level, integer edge) { if ((level & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) { if ((edge & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) { pos = llGetPos(); rot = llGetRot(); offset = <1, 0.0, 0.0>; offset *= rot; pos += offset; llPointAt(pos); } pos = llGetPos(); rot = llGetRot(); offset = <1.0, 0.0, 0.0>; offset *= rot; pos += offset; llPointAt(pos); vector fwd = llRot2Fwd(rot); fwd *= BULLET_VELOCITY; integer i = 5; rot *= llEuler2Rot(<0,PI_BY_TWO, 0>); llRezObject("[CS] SW [RTF]", pos, fwd, rot, 1); llSleep(REPEAT_DELAY); } else { if ((edge & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) { llStopPointAt(); } } } }
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
01-12-2009 00:26
This little change should do it:
llRezObject("[CS] SW [RTF]", pos, fwd, rot * llGetRot(), 1);
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-12-2009 00:32
more info at http://wiki.secondlife.com/wiki/RotationI also don't think you need that rot2fwd calculation in your fwd vector, or the extraneous multiplication on your rot at the end. but I may be misremembering. simplified I think it'd look like integer i = 5; rot = llGetRot(); pos = <1.0, 0.0, 0.0> * rot; llRezObject("[CS] SW [RTF]", pos + llGetPos(), pos * BULLET_VELOCITY, rot, 1);
ps according to wiki pointAt doesn't work anyways, apparently never did.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
01-12-2009 13:19
did the trick, knew it had to be something simple got to love scripting/programing
|