playMaker

Author Topic: Player ship collider isn't detecting enemy projectile[SOLVED]  (Read 1545 times)

JonV

  • Playmaker Newbie
  • *
  • Posts: 3
Hi everyone,
1st time posting, couldn't find the answer I was looking for after creeping the forums for a few days, hoping someone can help me make sense of this.

My game is a Starfox like rail game. I've got an AI ship that positions itself in front of my player ship and shoots a cube(bullet placeholder) towards my player ship. The setup is simple enough, the enemy ship has a "smooth look" towards my player at all times and fires the projectile slightly ahead of my player ship to offset the ship's constant forward motion. The enemy bullet shoots off and goes through my ship without detecting the trigger. Both my ship and the bullet has a rigidbody attached, and a box collider, with "Is Trigger" active on the bullet.

I tried changing the Rigidbody collision detection mode to Continuous and Continuous Dynamic but no luck either. The enemy bullet is fired using an Add Force with the force mode Impulse. The bullet does end up returning a trigger find(Made a script that detects it), but it's due to it crossing a spawn trigger I placed earlier in the level. I'm thinking perhaps that it might have something to do with my player ship being a child of an empty object? That empty object holds the script that causes the constant forward movement for my ship, camera and such. The ship movement is done using transitions and such, not using physics to move it. I'm out of ideas at the moment and would greatly appreciate a nudge in the right direction.

Thanks!
« Last Edit: May 23, 2017, 04:30:35 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Player ship collider isn't detecting enemy projectile
« Reply #1 on: April 19, 2017, 02:40:46 AM »
Hi and welcome :)

If your game is a top down, make sure the z depth is the same for your projectile and player, so change your view point in the scene view and check that they actually collide for real in all dimensions, not just from above.

Bye,

 Jean

JonV

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Player ship collider isn't detecting enemy projectile
« Reply #2 on: April 19, 2017, 10:15:00 AM »
Thanks for the welcome and response Jean!
My game camera lags behind my ship, so it isn't a top down view. I did check and slowly ran the game frame by frame to make sure the bullet collider intersected with my ship collider and it does. I increased the bullet collider size as well to make sure. I did put a tag on my player ship and my trigger event is looking for that same tag in order to finish the event to the next state. I'm kind of worried that because I'm using translates to move my ship and not physics that this is somehow causing the issue? However, that seems to go against the fact that my ship does actually seem to activate the waypoint trigger event I created to spawn my enemies. Maybe the forward motion of my ship plus the forward motion of the bullet makes the intersection too quick causing it not to detect? For now I keep hammering at it hoping for the best! 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Player ship collider isn't detecting enemy projectile
« Reply #3 on: April 21, 2017, 03:52:34 AM »
Hi,

 yes, that's seems odd indeed. Are you sure you have not messed up the collision matrix or something?

 Bye,

 Jean

JonV

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Player ship collider isn't detecting enemy projectile
« Reply #4 on: April 23, 2017, 04:56:55 PM »
Thanks for the great tip Jean, you put me on the right track!

I put my enemy bullet into it's own layer and I dug into the collision matrix and set it up so that the enemy bullets would only detect the layer i created for the player ship only. After some testing, it's now working better than intended, the enemy bullets are no longer returning a collision when hitting other game objects in my game, and i'm finally getting a return when the bullet connects to the ship!

Again, thanks for the big help!