Collisions: source and destination...
by Jason Cahill · in Torque Game Builder · 05/08/2006 (12:05 am) · 4 replies
Ugh... this is a bit frustrating. I think I understand WHY this happens, but it's still frustrating.
Here's my scenario:
I have two vehicles: (a) is stopped, (b) is moving.
Both (a) and (b) are set to send and receive collisions.
(b) runs into (a)
====| Result: onCollision(src = (b), dst = (a)) on the first call...
followed by a flurry of additional onCollision calls during subsequent frames where 1/2 the time (a) is the source and half the time (b) is the src.
Here's my thought: since (b) started it... shouldn't (b) always be the source when interacting with (a) until the issue is resolved? It's probably a terrible p-i-t-a to code, though. :-(
I think my work around is to look at the direction of each vehicle and based on speed and direction, "decide" a winner. The question is: How do you decide "what's in front" of a given sprite? I could do something cheesy like have a link point off the front of my vehicle and at collision time try to see if it's colliding with the other vehicle or vice versa.
The reason this matters is that I'm trying to make a particle spray based on the cause of the accident. I want it to be angled for the sender, not the receiver, but as currently implemented I get an equal spray in both directions.
Thoughts?
Here's my scenario:
I have two vehicles: (a) is stopped, (b) is moving.
Both (a) and (b) are set to send and receive collisions.
(b) runs into (a)
====| Result: onCollision(src = (b), dst = (a)) on the first call...
followed by a flurry of additional onCollision calls during subsequent frames where 1/2 the time (a) is the source and half the time (b) is the src.
Here's my thought: since (b) started it... shouldn't (b) always be the source when interacting with (a) until the issue is resolved? It's probably a terrible p-i-t-a to code, though. :-(
I think my work around is to look at the direction of each vehicle and based on speed and direction, "decide" a winner. The question is: How do you decide "what's in front" of a given sprite? I could do something cheesy like have a link point off the front of my vehicle and at collision time try to see if it's colliding with the other vehicle or vice versa.
The reason this matters is that I'm trying to make a particle spray based on the cause of the accident. I want it to be angled for the sender, not the receiver, but as currently implemented I get an equal spray in both directions.
Thoughts?
About the author
#2
05/08/2006 (12:29 am)
I've already got that set to "0". Thanks for the tip, though. :-)
#3
onCollision(src,dest)
if src.Xspeed = 0 and src.Yspeed = 0
return
else
threat collision spray effect
05/08/2006 (2:56 pm)
Can't you add something like : onCollision(src,dest)
if src.Xspeed = 0 and src.Yspeed = 0
return
else
threat collision spray effect
#4
05/08/2006 (3:09 pm)
Yeah, I've decided that in general to "canonicalize" my src and dst objects in the following way: highest speed is always the src. If neither is moving... bail.
Associate Melv May
I'm not sure if this will help because it is a global change but you can set the system variable "$pref::T2D::dualCollisionCallbacks" to false to turn off bi-directional collision callbacks.
- Melv.