Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need Help Creating an object that responds to impact from projectiles

Donald Tuttle
Registered User
Join date: 21 Jan 2007
Posts: 1
02-06-2007 22:31
I'm very new at scripting and I'd really like to setup a shooting range where the targets on the range are knocked over or even spun around by bullets hitting them. From what I've been able to figure out with the scripting tutorials, it sounds like ill need to have the target use llGetForce but I'm really not sure how to convert that force into motion in the target object.

Any advice? Thanks!
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
02-07-2007 10:17
Seems to me there (at least) two approaches.

    Make the targets and the bullets physical. When a bullet hits a target, the target will react (thanks to Newton, the inventor of force 8-).


    Use detection. A script in the target would get an event when it is hit by a bullet. It can then explode, spin, say "Ouch", or anything else you can script.


    Fake it. No bullets. Just *pretend* the targets are hit once in awhile.

Lazarus Wake
Registered User
Join date: 9 Jan 2006
Posts: 33
02-07-2007 11:58
I'm not sure I would trust physics to do that. Even in the best of cases the physics engine seems a little wonky and if you are trying to create a hinge at the bottom or a pivot in the center I think there's a good change you'll end up making SL cry.

A non-physics based solution would be to simply have a collision event on the target. When the collision event is triggered you call llTargetOmega() to spin the target. In the case of a target that's 'knocked down' you rotate the target back for a predetermined amount of time through llTargetOmega() followed by llSleep() then llSetRotation and stop the llTargetOmega(). To make sure you rotate on the bottom of the target rather than the center just use the cut property to make your target half its normal height.