Calculate collision for specific objects?

Started by xNaXDy, May 27, 2012, 10:54:49 PM

Previous topic - Next topic

xNaXDy

Basically I need a function that allows me to calculate if my 'player' is colliding with any of the 'enemies'. The function must NOT be called when 'player' collides with 'block' for example.

Do you know how to accomplish this?

EgonOlsen

You can make all these objects (enemy, block...) collision aware (http://www.jpct.net/doc/com/threed/jpct/Object3D.html#setCollisionMode(int)) and add an implementation of the CollisionListener interface to your enemies. When using the build-in collision methods, the interface's collision()-method will be called if anything collides with the enemy.

xNaXDy

I don't quite get the thing with check_self and check_others. Also what would I have to do if there was like 19 different types of enemies?

vickt

check_self lets other objects collide with the object, check_others lets that object collide with others. You can use the | to combine them.

After finding the object ID with one of the collision methods, you can compare it to a list of your Enemy and Block's object IDs.