Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Controlling Velocity of an object

ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
04-23-2008 09:34
I have made a Piranha Attack and several other attack creatures that bump and push any avatars that come too close to them. A role play group has been using the Piranha with thier combat system, which apparantly was changed recently and my Piranha no longer damage them. I have been told that in order for damage to occur now " the velocity of the collision must be above 15 m/s now".

I cannot seem to find anything in the Wiki about how to determine or control the velocity of an object. My Piranha use llPushObject(llDetectedKey(0), <0,110,0>, ZERO_VECTOR, FALSE).

Adjusting the vector <0,110,0> controls how hard it pushes, but I don't see how to correlate this with velocity.

Any insights would be appreciated.
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-23-2008 11:23
Pushes and collisions are independent. A script in an attachment can't detect a push, though it could monitor for sudden changes in velocity (that are not correlated with a collision) and make assumptions about the reason. I'm not sure how your push was EVER causing, "damage." My suspicion is that it was due to a collision and not a push (even if both were happening), so you are looking in the wrong part of your code. I could be wrong though. The attachment could be detecting changes in velocity as mentioned above, in which case you'll want to calculate the impulse with something like:

CODE

vector calculateImpulse(vector direction, float speed, vector targetPos, float targetMass)
{
float dist = llVecDist(targetPos, llGetPos());
return targetMass*direction*speed*llPow(dist, 3.0);
}


(where speed is at least 15.0) as described in http://www.lslwiki.net/lslwiki/wakka.php?wakka=llPushObject