Jump to content

laser that rezzes in front of you on command - how to?


asteriddle
 Share

You are about to reply to a thread that has been inactive for 941 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

figured i'd finally ask instead of trying to figure it out myself because im Tired

i want to make a laser (mesh temp phantom vfx object) rez in front of the avatar, facing in the shooting direction, on command.

i have the 'on command' part figured out already, but can't for the life of me get it in proper position and rotation. for clarification, i want the laser to shoot forwards in the direction the avatar is facing. so if my avatar is facing left, i'd assume i'd call for the z axis rotation and have the laser be rotated in that direction to match? but i can't really seem to figure it out

the other problem is position, as the laser will rez in at the laser object's root. i'm... not quite sure how to offset it to it rezzes at the start of the laser facing the direction i want

 

hopefully that makes sense!

Link to comment
Share on other sites

So, it kindof depends how your lazerbeam is built, but I'll assume it's basically a cylinder that's long on the z axis, and its center is in the middle of the cylinder (not on the end).

If you don't care which part of the lazer is facing up or down (because it's basically a symmetric cylinder) you can specify its rotation parameter as

rotation rotAvatar = llGetRot(); // you need the rotation of the avatar. if this script is in an attachment, llGetRot() will give you the rotation of your avatar.

rotation rotLazer = <0,0.71,0,0.71>*rotAvatar; // should be equivalent to (commented out) next line.
//rotation rotLazer = llRotBetween(<0,0,1>,<1,0,0>)*rotAvatar;
//rotation rotLazer = llROtBetween(<0,0,1>,rotAvatar); // above version probably slightly better.

(was also going to talk about position, but Rolig answered first. . .)

. . .

Rolig's answer works if your lazer is built such that it runs along the x-axis.

  • Thanks 1
Link to comment
Share on other sites

23 minutes ago, asteriddle said:

 

the other problem is position, as the laser will rez in at the laser object's root. i'm... not quite sure how to offset it to it rezzes at the start of the laser facing the direction i want

 

Plan B. Cheat.

The laser beam is part of the attachment invisibly extending out as far as you care to make it. Firing the laser turns it visible for a split second, add PEW PEW sounds.

Make it extra pretty by making the beam a mesh divided into sections from start to end, light each section in sequence with a with a sliding texture map.

  • Thanks 1
Link to comment
Share on other sites

58 minutes ago, Quistess Alpha said:
rotation rotAvatar = llGetRot(); // you need the rotation of the avatar. if this script is in an attachment, llGetRot() will give you the rotation of your avatar.

rotation rotLazer = <0,0.71,0,0.71>*rotAvatar; // should be equivalent to (commented out) next line.
//rotation rotLazer = llRotBetween(<0,0,1>,<1,0,0>)*rotAvatar;
//rotation rotLazer = llROtBetween(<0,0,1>,rotAvatar); // above version probably slightly better.
1 hour ago, Rolig Loon said:

llRezAtRoot( "MySuperLaserGun", llGetPos() + <2.0,0.0,1.5>*llGetRot(), ZERO_VECTOR, llGetRot(), 0);

these in tandem worked perfectly, thank you so much!! i can now shoot giant rainbow lasers at will

==

unrelated, while it DOES work now, it looks a little stale - i had originally planned to make it rotate around this way (see image), but using the examples of the wiki for llTargetOmega , it will end up spinning fine at some angles but wildly in the incorrect direction at others

(blender pic because im not inworld atm)

unknown.png

(i do know of texture animation, and the rainbow is actually animated in that fashion, but using llTargetOmega gave it a nice 'wobble' when i was putting it together)

Link to comment
Share on other sites

1 hour ago, Quistess Alpha said:

Rolig's answer works if your lazer is built such that it runs along the x-axis.

Yeah, I forgot to specify that assumption.  Thanks, Tessa.  I always make sure that anything I build in SL has the Z axis vertical and -- if it's something to attach to me -- that it's +X axis points forward.  If it's hard to build with those constraints, I link the object to a transparent root prim that has the proper orientation.  That saves a whole lot of messing around with rotations in my scripts.

Link to comment
Share on other sites

9 minutes ago, asteriddle said:

llTargetOmega

IIRC, omega is applied in global coordinates relative to the objects current rotaiton when you apply the omega. best to create a somple omega script first and once its rotating corectly it will stay rotating the same if you change its orientation.

  • Like 1
Link to comment
Share on other sites

32 minutes ago, Quistess Alpha said:

IIRC, omega is applied in global coordinates relative to the objects current rotaiton when you apply the omega. best to create a somple omega script first and once its rotating corectly it will stay rotating the same if you change its orientation.

this is the exact script i use for the actual laser (not the trigger/rezzer), not including the llDie and temp flags, taken from the wiki except with axis changed - yet each time i call for the laser, the direction it spins in is different despite it being set up separately and rotating the way i want it to in its original, non hud rezzed version

 //Rotates very slowly around a cylinder's local or global Z axis
 // .... Good for making a propeller that rotates regardless of initial orientation.
 
default
{
    state_entry()
    {
       llTargetOmega(llRot2Left(llGetLocalRot()), PI, 1.0);
    }
}

 

Link to comment
Share on other sites

3 minutes ago, asteriddle said:

this is the exact script

IMO, rez your lazer normally, without the HUD, then add the script, then mod it so it rotates correctly, then remove the script. Add the correctly rotating lazer back into the HUD.

Edited by Quistess Alpha
Link to comment
Share on other sites

1 hour ago, Quistess Alpha said:

IMO, rez your lazer normally, without the HUD, then add the script, then mod it so it rotates correctly, then remove the script. Add the correctly rotating lazer back into the HUD.

i tried, and it fires correctly when facing east or west. but when facing north or south, it still rotates with the long side swinging, instead of the 'propeller' like motion.

the script had been removed aswell

Link to comment
Share on other sites

21 minutes ago, asteriddle said:

i tried, and it fires correctly when facing east or west. but when facing north or south, it still rotates with the long side swinging, instead of the 'propeller' like motion.

the script had been removed aswell

oh, try replacing state_entry() with on_rez() and se if that does much.

  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 941 days.

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
 Share

×
×
  • Create New...