Game Development Community

Projectile collision with owner

by J Wright · in Torque Game Builder · 06/20/2009 (8:32 am) · 3 replies

I am creating a projectile based on my player's location and rotation. The problem I have is that it collides with my player instantly (therefore exploding), for obvious reasons. I want this projectile to be able to collide with the player if it were to bounce back, etc, so it's not just a matter of turning off a collision layer.

My thought was that I could start the projectile at a point outside of my player's collision poly, but I'm not sure how to do that effectively. Do I need to create a short vector based on my player's location and rotation to determine a coordinate outside of his collision poly, and if so, how do I do that? Or am I going about this all wrong?

Thanks!

#1
06/22/2009 (1:28 pm)
Perhaps you've solved this by now, but if not, one thing you might try doing is to turn off collisions with the owner initially, then when the projectile collides with something turn the collisions for the owner back on.

I don't know how your bouncing code works, but I'm guessing that the projectile would run into something, and bounce off. Which would mean that its onCollision method would get called. If you put some code in there to turn collisions with the owner back on, then you wouldn't have to worry about it, because the onCollision method would always get called before the projectile could possibly collide with the player.
#2
06/22/2009 (2:20 pm)
@Darius

Thanks. What I ended up doing was creating an offset based on my player's size, angle and rotation for the projectile's start position. In other words, I am starting the projectile outside of my collision poly.

#3
06/22/2009 (4:06 pm)
Quote:I want this projectile to be able to collide with the player if it were to bounce back, etc, so it's not just a matter of turning off a collision layer.

Depends on the point of view.
I would still have it done that way and just added the players layer again on the first collision with something else as you know that the first bounce will never be the player but after that initial bounce it always could be the player