|
Lucius Nesterov
Registered User
Join date: 12 Oct 2006
Posts: 33
|
02-15-2009 13:01
Hey,
I'm trying to create a system where a projectile can hit an object, and that object records damage. I've tried two approaches, but they have problems and I was wondering if people had had better success with a different method.
Method 1: On collision the projectile makes an announcement on a channel - giving its position, damage amount and blast radius.
Objects listen for damage announcements, calculate their distance from the source, and whether they're within the blast radius.
Problem: It works OK on low-lag sims, if the projectile switches non-physical at the point of collision, but in laggy sims they have bounced some distance away before announcing and so are inaccurate.
Method 2: The projectiles have names like proj_xx, where xx is the damage amount.
Objects detect collisions and use the name to determine how much damage to take.
Problem: The projectiles have to remain alive long enough for llKey2Name(llDetectedKey(loopNum)) to run; which means a) they look ugly sitting around after collisions, and b) they can ricochet into other objects.
Any better options?
Cheers
|
|
Jack Abraham
Lantern By Day
Join date: 11 Apr 2008
Posts: 113
|
02-16-2009 07:30
I use a variant of (2) where the object on collision immediately turns invisible, phantom, and non-physical (and temp-on-rez if it wasn't already). This allows it to linger long enough for it to be read, without cluttering up the landscape.
|
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
02-16-2009 07:46
From: Lucius Nesterov On collision the projectile makes an announcement on a channel - giving its position, damage amount and blast radius.
Objects listen for damage announcements, calculate their distance from the source, and whether they're within the blast radius.
Problem: It works OK on low-lag sims, if the projectile switches non-physical at the point of collision, but in laggy sims they have bounced some distance away before announcing and so are inaccurate. If they use llDetectedPos() instead of llGetPos()?
|
|
Lucius Nesterov
Registered User
Join date: 12 Oct 2006
Posts: 33
|
02-17-2009 05:47
Thanks for the suggestions.
After a bit of playing I've gone with a reverse of method 2, where colliding objects announce damage for the target (targetKey:damage amount). Its not ideal, but way I can also use the same system for melee attacks (with a sensor picking who's in range).
|
|
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
|
02-17-2009 14:59
Keep in mind that any system using Object Names is going to be easy for anyone else to do whatever they want with.
---
The Chat problem thing I eventually solved by the first things you do on collision_start:
Record Position ( DetectedPos(0) works best against Lag ) Set Phantom TRUE Set Physical FALSE
Then send your message with the Position and Range included, letting the Meter for people/objects do a if( llVecDist(InPos, MyPos) <= InRange ) check.
Then Die, ofcourse.
|