Yet another collision issue (solved)

I was doing all my collision detection by collision solids, and no problem with that. But then, I thought that projectiles fired by my avatar shouldn’t pass through the walls. As the whole architecture is kind of complex/tedious to wrap with collision solids, I used

setFromCollideMask(BitMask32.bit(2) | GeomNode.getDefaultCollideMask())

in the missile so I could handle walls too. Somehow I got it to collide with walls, but a problem arised with that modification: Sometimes when the missile hits a target that used to work nice before, the collision queue has hundreds (literally) of entries.

I suspect the missile is colliding with target vissible geometry instead of its collision sphere. My question is: what should I do about it? (if I can do something) Doing the collision sphere larger doesn’t seem to work. Do you think a possible solution would be to make some visible geometry collidable and some not? (If it can be done, of course)

GeomNode.getDefaultCollideMask() is the bit that is set on by default for all visible geometry, so you have asked your missiles to collide with all visible geometry.

Instead of doing that, if you wish your missiles to collide with just the visible geometry of your walls and not with other visible geometry, you can instead set the into mask of those walls to match your missile:

walls.setCollideMask(BitMask32.bit(2))

It would, of course, nevertheless be better to make collision solids for your walls–you should understand that this solution is far, far from optimal–but it will do in a pinch.

David

Thanks David, your advice was useful once again, collisions seems to work better now.

I do know that collision solids is the way to go, but I wanted to spare me to set collision solids around the buildings. Besides, performance is not an issue, as my game is closer to an extended ralph demo than to a commercial game