Jump to content

Non-Floor Collision Detection


druphoria
 Share

Recommended Posts

I'm trying to write code to make my enemies change the direction they are moving in when they run into an object or a wall. Right now I have a single tilemap - I tried to create a second layer (where i put everything that could be collided with) within this tilemap and change the enemy direction in a callback function when the enemies collide with this second layer, but I discovered that Phaser currently only supports collision with one layer. What would be the recommended way to do this (aside from creating a second tilemap)?

Link to comment
Share on other sites

Oh awesome - thanks. That will definitely be handy. I actually ended up implementing another solution last night - basically I stored the enemy's previous x position and check within the "update" method if the x position has changed. If it hasn't changed since the last time update was called, then I change the direction. Great to know that there is a way to have callback on specific tiles though.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...