Gene Jacobs
Who? Me?
Join date: 30 Jul 2004
Posts: 127
|
08-25-2004 10:46
Does anybody have a script for when an object (lets say a ball) with physics set, touches another object, there will be a bounce or push away? Kind of like a way, to put a ball in a tube. When the ball touches the bottom, it is repelled or bounces. The action will allow the ball to fall back down and continue the cycle.
_____________________
SL Defined = The reason that we are all here, is because we are not all there... 
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
08-25-2004 11:19
Well, you have llGetPos(), which returns the object's position, and you have llDetectedPos(), which you can call in a collision_start() event to get the position of the object you're hitting. As long as the object you're colliding with is relatively small, and not a weird cut shape, llGetPos() - llDetectedPos(0) will give you a vector away from the object you collided with. So you could have something like force fForce = 9.8; // how hard to push the object bounce(vector vDir) { vector vImp; vImp = llVecNorm(vDir); vImp = vForce * vImp; llApplyImpulse(vImpFalse); } then in your state: collision_start(integer n) { bounce(llGetPos() - llDetectedPos(0)); }
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|