Reply
Honored Resident
alana1275 Riddler
Posts: 57
0 Kudos

help with gun script please

Hi everyone

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>;

integer velocity=40;

f()

    {

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

 

Thanks



Rolig Loon
Posts: 24,914
Registered: ‎10-05-2009

Re: help with gun script please

Reply to alana1275 Riddler - view message

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);

Not as dumb as I look
Posts: 930
Registered: ‎10-05-2009

Re: help with gun script please

Reply to alana1275 Riddler - view message

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.

http://www.msdcs.co.uk/v2combat_meters/

http://marketplace.secondlife.com/stores/18253
Honored Resident
alana1275 Riddler
Posts: 57
0 Kudos

Re: help with gun script please

Reply to Rolig Loon - view message

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:smileyhappy:))

Honored Resident
alana1275 Riddler
Posts: 57
0 Kudos

Re: help with gun script please

Reply to Lucinda Bulloch - view message

Hi,  yes its made up of several sculpts.   Thank you for explanation - mades it a lot clearer why it was doing it.