02-15-2012 02:46 AM
I'm still fairly new to scripting and am having some trouble with this script which fires gun bullets. It works all fine apart from when the bullet is rezzed and travels outwards it is at the wrong orientation - instead travelling head first, its travelling sideways first.
I'm sure this is to do with llGetRot(); returning the wrong values - the object is getting rezzed in the wrong orientation with respect to it's container. Anyways, I've searched and looked up the first of the four functions in the script and understand them better but just had no luck at all getting the bullets to fire out correctly.
Here is the part of the script that is having trouble:
vector gEyeOffset = <0.0, 0.0, 0.84>;
vector my_pos = llGetPos() + gEyeOffset;
rotation my_rot = llGetRot();
vector my_fwd = llRot2Fwd(my_rot);
llRezObject("Bullet", my_pos, my_fwd * velocity,my_rot,1);
Any help appreciated
02-15-2012 08:02 AM
Without really knowing what the "correct"orientation is supposed to be, all I can do is guess. Tha answer, however, is to just add an appropriate rotation to the one you are applying to the bullet on rez. If you want to turn it 90 degrees, for example ...
llRezObject("Bullet", my_pos, my_fwd * velocity,llEuler2Rot(<0.0,0.0,PI/2>)*my_rot,1);
02-16-2012 12:17 AM
Is the bullet a sculpt, if so then its the bullet not the script, that script rezzes a object with its x face in front, but if you bullet has been made with the y face in front then it will travel side ways, you can get round this by adding a prim, making that the root and with its x in the same direction as the bullet front, that what I do when ever I use sculpty bullets or weapons.
02-16-2012 02:52 AM
Thank you for your help, yea I saw llEuler2Rot() on the lslwiki but wasn't sure of its application. But tried as you suggested, worked out the correction to the rezzed orientation and it worked))