Game Development Community

Collisions

by Victor Ferenzi · in Torque X Platformer Kit · 01/12/2009 (9:21 am) · 3 replies

Hi,

I have a question on how to determine when a bullet has collided with an enemy. I have set up my enemy to collide with BULLET and I have setup my bullet to collide with ENEMY.

My bullet uses a component simular to the Bomb component in Torque X Tank Blaster. So my OnCollision method is being triggered when the bullet comes close to the enemy.

The problem is the bullet collision seems to be in front of the enemy not when it intersets with the collision polygon.

Is there some type of checking that needs to be done to determine when these two interset. I was under the impression that the PSK handled that. Not a problem just would like to know if additional checking is needed and maybe a sample of what to check. The method passes in the bullet, enemy, and collision info objects.

Thanks,
Victor

#1
01/12/2009 (6:20 pm)
First thing I would check is the collision polygon for the bullet.

Also, you stated, "My bullet uses a component simular to the Bomb component in Torque X Tank Blaster. So my OnCollision method is being triggered when the bullet comes close to the enemy", though it sounds like you really want OnCollision called when the bullet collides with the enemy. Not trying to be a jerk about your wording, but I'm not familiar with the workings of Tank Blaster, do the bombs explode when near an enemy or when they collide with the enemy?

You might also check out the Space Warrior tutorial, as it does some collision handling along the lines of what I think you are trying to accomplish.
#2
01/13/2009 (12:15 pm)
Hi Sean,

I will check out the tutorial you mentioned. And yes I would like the method to fire when the bomb collides with the enemy.

You also mentioned to check the collision polygon for the bullet. I am fairly new to the PSK so could you expand on how that would be accomplished?

Thanks,
Victor
#3
01/13/2009 (1:03 pm)
Quote:You also mentioned to check the collision polygon for the bullet. I am fairly new to the PSK so could you expand on how that would be accomplished?

In the Space Warrior tutorial, to make a bullet you first create a scene object in Torque X Builder. You can then edit the bullet's collision polygon in TXB just like you would for players or enemies. If you don't do this I believe the bullet's collision polygon defaults to the dimensions of the image used for the bullet.

Once you've got your bullet all set up in TXB you simply clone it in your code. This is all explained better and with greater detail in the tutorial.