Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llApplyImpulse and me

Bond Harrington
Kills Threads At 500yds
Join date: 15 May 2005
Posts: 198
08-19-2005 15:46
I was looking around to find away to counteract recoil with llApplyImpulse. When llApply Impulse is on the gun has a delay, of course, and I've heard that you can have the bullet apply the impulse on the shooter on rez. Is there a piece of script I can use for this, because I do not know how to do that? It would be easier to use this on the shooter, since I can calculate the bullet mass and speed easier from the projectile.

Also, can I use llApplyImpulse as a booster for a projectile already in motion?
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
08-19-2005 23:11
If the execution time of the on_rez event is fast enough, you may be able to get away with calling llPushObject from the projectile to negate gun recoil. As for your second question, yes :D

Example code in projectile:
CODE

default {
on_rez(integer param) {
// We're assuming the gun that fired this bullet is attached to the owner here.
llPushObject(llGetOwner(), -llGetVel() * llGetMass(), <0, 0, 0>, FALSE);
}
}

I *think* that should work.

As an easier alternative, you can just make the gun llMoveToTarget(llGetPos(), 0.5) before rezzing, and llStopMoveToTarget a few tenths of a second later. That should prevent the llRezObject from moving the avatar.
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Bond Harrington
Kills Threads At 500yds
Join date: 15 May 2005
Posts: 198
08-20-2005 07:28
Thanks. I actually got the llApplyImpulse to work on the gun, but I found out that if I use multiple rez scripts, it starts up a weird back-forward movement on the other rezzes. I'll probably end up llPushObject on Owner, unless there's an llApplyImpulse that can work.

With the second one, I might end up having to revisit my rocket launcher.