sufferot Posted July 25, 2012 Share Posted July 25, 2012 Uuummm... Hello. I'm not very good at LSL scripting, but trying to make a basic crossbow. I made model, textures and take "opensource" script from LSLlibrary. But I have one issue... My arrows rez vertically. The "head" of arrow placed not on target, but in sky. Can somebody help me?Script:.float BULLET_VELOCITY = 75.0; float REPEAT_DELAY = 1.0; string gunsound = "armrmed1"; string gunanim = "hold_R_bazooka";string ammo = "Bolt_script"; (script body) control(key owner, integer level, integer edge) { if ((level & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) { // Mouse down if ((edge & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) { llPlaySound("armrmed1",1.0); // Rezz the bullet object with a specified velocity llRezAtRoot("bolt_script", llGetCameraPos()+<1.5,0,0>*llGetCameraRot(), BULLET_VELOCITY *llRot2Fwd(llGetCameraRot()), llGetRot(), 10); llSleep(REPEAT_DELAY); } } }} Link to comment Share on other sites More sharing options...
Rolig Loon Posted July 25, 2012 Share Posted July 25, 2012 Well, the rotation you're using in llRezAtRoot is evidently wrong. Instead of using llGetRot(), you're going to have to multiply it by a correcting rotation. Not knowing what the geometry of your rezzer or arrow looks like, it's hard to say exactly what rotation to suggest. Try the usual suspects, though, and see what happens.. llEuler2Rot(<0.0,PI/2,0.0>) * llGetRot() or llEuler2Rot(<PI/2,0.0,0.0>) * llGetRot() Link to comment Share on other sites More sharing options...
sufferot Posted July 25, 2012 Author Share Posted July 25, 2012 thx you, that helps :3 Link to comment Share on other sites More sharing options...
Innula Zenovka Posted July 25, 2012 Share Posted July 25, 2012 It's a bit difficult to know for sure, without knowing how the arrow is made, but, from what you say, I infer that it's conventionally made, in that the positive Z axis is pointing upwards, and you want it to be rotated through 90 degrees on the Y axis. Try that with a rezzed arrow, and see it is, in fact, what you want. If it's not, post the details here. Anyway, assuming I'm right, I think this should do it float BULLET_VELOCITY = 75.0; float REPEAT_DELAY = 1.0; string gunsound = "armrmed1"; string gunanim = "hold_R_bazooka";string ammo = "Bolt_script"; rotation r;// You could define this here as =<0.00000, 0.70711, 0.00000, 0.70711>; but I'm calculating it in state entrydefault{ state_entry() { r = llEuler2Rot(<0.0,90.0,0.0>*DEG_TO_RAD); //90 degrees on the Y axis } control(key owner, integer level, integer edge) { if ((level & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) { // Mouse down if ((edge & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) { llPlaySound("armrmed1",1.0); // Rezz the bullet object with a specified velocity llRezAtRoot("bolt_script", llGetCameraPos()+<1.5,0,0>*llGetCameraRot(), BULLET_VELOCITY *llRot2Fwd(llGetCameraRot()), r* llGetRot(), 10); llSleep(REPEAT_DELAY); } } }} The fourth argument in llRezAtRoot(), the rotation, means the rotation relative to how the rezzer is (in this case, since it's an attachment, relative to how you are). You've said, llGetRot(), which means "the same rotation as me", and since your standing vertically, the arrow does, too. My alteration, r*llGetRot*(), means "angled at 90 degrees on the Y axis to how I'm standing", which should be what you want. ETA Rolig got there first. Her calculation is the same as mine, just expressed differently. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now