Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

One-shot?

Oberon Onmura
Registered User
Join date: 28 Dec 2006
Posts: 125
02-25-2009 06:54
Hi. Sometimes I get a double "hit" when I enable a collision_start event. It doesn't seem to matter what the shape of the target prim is - occasionally when something collides with it it runs two of whatever functions are in the event handler. I'm using it with llVolumeDetect.

Any thoughts? Is this a known bug? Any ideas about writing some kind of one-shot to prevent this?

thanks!
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
02-25-2009 11:11
Save the key of the detected collision, and set a timer, if your saved key is NULL then it's a new collision, if it's not then run the collision code you want. The Timer event should clear the saved key.
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
02-25-2009 16:25
@Lazink: Little easier, IMO, to compare a Stored Key and the current Detected Key.
If they match, return or do whatever for rejected collisions.
If they don't, set the Stored Key to the Detected Key, then do whatever other processing.

(Your mention of the Timer leads into another thing; Throttling. But there's an easier way to do that.

float Coll_Delay;
float Coll_LastTime;

integer ThrottleCheck()
{
Time = llGetTime();
if(Time - Coll_LastTime >= Coll_Delay)
{
Coll_LastTime = Time;
return TRUE;
}
else
{
return FALSE;
}
}

Saves having to use an unneeded timer.)
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
02-25-2009 17:04
Just a matter of opinion, no big deal. Never really a "absolute" way to do stuff. But if you wanted to check, which is faster, having the throttle, which calls a check, then does two comparison, or a timer that fires once, shuts itself off after it's fired. I don't know which creates less sim lag, and quite frankly, for a tiny thing like that, does it really matter? :) (granted there may be a whole bunch of other things, or a timer is being used or, etc.)
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
02-25-2009 19:51
Yeah. That's why I used the IMO there. As for the GetTime check, I guess it depends on the length of your throttle and if you're using the Timer Event for other things.

Throttle Length less than 2 seconds and/or already using the Timer, I'd use the GetTime check. Otherwise yeah, the Timer would be better.
Oberon Onmura
Registered User
Join date: 28 Dec 2006
Posts: 125
02-26-2009 18:42
Thanks for these ideas. I'm not sure, though, that there is any time between detections. It's like one detection produces two "hits".