Alpha 3b Collision Bug?
by Toby Mckenzie · in Torque Game Builder · 01/31/2006 (3:05 am) · 7 replies
I have a situation where I have a number of sprites (shot gun pellets), being fired towards an enemy sprite (zombie). The shotgun pellets have a collision response of Kill and in the onCollision callback the enemy sprite (zombie) is deleted. What I am seeing is that the shotgun pellets are not being killed / deleted when the collide with the enemy sprite, if the enemy is deleted within the onCollision, i.e
However if I do not delete the the zombie sprite i.e:
Then the shotgun pellets are deleted as I would expect.
function t2dSceneObject::onCollision(%srcObj,%dstObj,%srcRef,%dstRef,%time,%normal,%contactCount,%contacts)
{
if (%srcObj.tag $="playerBullet" && %dstObj.tag $="zombie")
{
%dstObj.safeDelete() ;
%srcObj.safeDelete() ;
}
}However if I do not delete the the zombie sprite i.e:
function t2dSceneObject::onCollision(%srcObj,%dstObj,%srcRef,%dstRef,%time,%normal,%contactCount,%contacts)
{
if (%srcObj.tag $="playerBullet" && %dstObj.tag $="zombie")
{
%srcObj.safeDelete() ;
}
}Then the shotgun pellets are deleted as I would expect.
About the author
#2
- Melv.
01/31/2006 (4:57 am)
Just one question; why are you deleting the projectiles in the callback when the collision response for it is kill anyway. This shouldn't affect things but it does seem a strange thing to do.- Melv.
#3
01/31/2006 (5:07 am)
Good point, think it is just a legacy (i.e me hacking code) from trying to get the projectiles to delete when they where not getting deleted through the kill response. Also worth noting for your debugging / recreating that the projectiles had a setLifeTime(0.3) on them as well.
#4
I'll let you know what I find here.
- Melv.
01/31/2006 (6:10 am)
Okay, thanks. I'll look at it this evening when I get home.I'll let you know what I find here.
- Melv.
#5
01/31/2006 (11:22 am)
Looks like I made a mistake somewhere as it appears to be working fine now, changed so much code today though cannot isolate what I was doing wrong.
#6
That's no problem. If you do find out what was going wrong then by all means post back here and let me know.
Glad it's working for you though. :)
- Melv.
01/31/2006 (11:28 am)
Toby,That's no problem. If you do find out what was going wrong then by all means post back here and let me know.
Glad it's working for you though. :)
- Melv.
#7
01/31/2006 (1:20 pm)
Hmm, when I put setCollisionPhysics(false,true) on the projectiles I seemed to get the same behaviour again, comment it out and the problem dissapears. In the onCollision method I am not deleting the projectile, rather relying on the collision response of Kill which does not seem to be happening when the setCollisionPhysics is set as per above.
Associate Melv May
Thanks for the report Toby,
- Melv.