Game Development Community

Collision Type

by Xavier "eXoDuS" Amado · in Torque Game Engine · 05/15/2002 (1:42 pm) · 7 replies

In function: void Projectile::explode(const Point3F& p, const Point3F& n, const U32 collideType )

the collision type is passed, which is a mask (TerrainObjectType|InteriorObjectType|PlayerObjectType, etc) but i cant seem to be able to check it...

i added an if like this: if (collideType == PlayerObjectType){, but it will never check true.. i added a few bots to the game shooted the hell out of em but that code never resulted true... any ideas what im doing wrong? a similar method works perfectly in onCollision()

#1
05/15/2002 (1:45 pm)
I think you have to OR or XOR the mask out, but then again my C/C++ is pretty rusty right now, and I have been writing Java code all day long!

EDIT:
My bad after looking at some example and seeing the posts below it is indeedy the AND ( & ) that will unmask the bitmasking
#2
05/15/2002 (1:47 pm)
you should do type & .... to make the test xavier
#4
05/15/2002 (3:29 pm)
wait, this didnt completely work...
i did

else if (collideType & (TerrainObjectType)){
//code here
}

but it works randomly, i mean... most of the time it checks false.. sometimes it checks true and runs the code in that if...
:(
#5
05/15/2002 (3:37 pm)
its kind of hard to see what your doing but.
that test should work fine

if(col & TerrainObjectType)
{
...
}

but are we asking the right question?
maybe:
if(obj->getType() & TerrainObjectType)
{
...
}

Edit :
where did collideType come from?
is this the mask your using for a collision test?
or did you extract it from an object?
#6
05/15/2002 (3:55 pm)
badguy, no my collisionType is already an U32... getType() gets from a U32 from a SceneObjects well this function gets an U32 passed instead of a SceneObject...
#7
05/15/2002 (3:57 pm)
duh, sorry scrolling up again I see that :)