Jump to content

Wanting to make an attached object fire at an avatar no matter where they are positioned around me


sisgenesis Aeon
 Share

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

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

Recommended Posts

So im trying to make a attached obejct fire in the direction of a target no matter what their position is around me. So if they are to the left of me the object will fire out left, behind then behind, 45 degrees to my right.....etc etc. Any info or examples on how this can be achieved. Like how do i take my position, their position and my rotaiton and make this happen

 

Link to comment
Share on other sites

You never actually said that the weapon itself is supposed to turn to face the target, so the solution is quite simple:

llRezAtRoot("Bullet", llGetPos() + <0.5,0,0> * llGetRot(), Fudge * (llDetectedPos() - llGetPos() ),ZERO_ROTATION,1);

where Fudge is a scaling factor that you'll have to figure out by experimentation.  The bigger it is, the faster the bullet will fly. Don't forget to make the bullet physical.

If you actually want to point the weapon as well, then Ruthven is right.  You can use

llRotLookAt( llRotBetween(<1.0,0.0,0.0>,llVecNorm( llDetectedPos() - llGetPos() ) ), 1.0, 0.4 );

 assuming that the weapon's muzzle end is its +X end.

 

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...