Collision Listener but then remove an object?

Basically, what I’m trying to do is something like this:



A vector of bullets or enemies that have individual behavior. If bullet/enemy collides with the scene, or anything else solid, it will get destroyed. BUT if it collides with the player, it should subtract some health and THEN get destroyed.



I’d like to know if and how this would be possible with Vector enemies ?



Thanks!

what is “vector enemies”? anyway you can do that by doing ray tests along the bullet path for as long as it flies and then check and sort the results and bullet path accordingly.

The Vector class is stored in java.util.vector and is some kind of list for the enemies. The class Enemy would then be a simple class to simulate enemy behavior.



The main question is how do I “remove” the bullet and subtract health at the same time. Is this possible within a single function?



Edit: Also, would it possible to determine WHICH of the enemies is colliding, just in case they do a different amount of damage?

Please look at what data the solution I suggested provides you with. I cannot say how you can do things in your own code, thats up to you.