Ernst Osterham
Registered User
Join date: 29 Oct 2008
Posts: 26
|
07-29-2009 03:39
I'm having no end of trouble getting an attached gun to rez spent shells at a consistent position relative to the avatar. Everything I have read on this forum seems to say that you simply multiply the offset by the avatar's rotation and that should translate it, though even though I am doing that in the script, the position still shifts around as the avatar turns.
rot = llGetRot(); pos = llGetPos(); rez_rot = ZERO_ROTATION; offset = 0.5, -0.25, 0.8; //editted to be able to post rez_pos = pos+offset*rot; llRezObject("SPENT CASE",rez_pos,ZERO_VECTOR,rez_rot,1);
This is the code I am working with, and it never seems to rez the shells at a consistent spot from the gun as you turn, though I can't for the life of me figure out why.
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
07-29-2009 05:18
Two points. I think you need to calculate the relative offset at run-time, when you actually rez the object. And also (though I am not sure how much of an issue it would be here) you might need to multiply the object's rotation by llGetRot(), too, if the problem is that it's not rezzing at the right local rotation (angled the right way up and the right way round). Try something like vector offset = < 0.5, -0.25, 0.8 >; llRezObject("SPENT CASE",llGetPos()+offset*llGetRot(), ZERO_VECTOR, ZERO_ROTATION*llGetRot(),1);
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
07-29-2009 12:35
there is one small problem you won't be able to control... avatar rotations aren't reported accurately by the server unless you are in mouselook. if you are in normal view the server uses a higher margin of error (because the viewer doesn't report smaller movements? I think)
otherwise the formula is fine, if it all runs before each shell is rezzed, and the script is in the root prim (if not, I suggest using llGetRoot* instead)
so maybe vector gPosOffset = < 0.5, -0.25, 0.8 >;
llRezAtRoot( "SPENT CASE", llGetRootPosition() + gPosOffset * llGetRootRotation(), ZERO_VECTOR, ZERO_ROTATION, 1 );
note that in either case when attached, the rez point is relative to the av's pelvis, and when not attached, the it is relative to the gun.
_____________________
| | . "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... | - 
|