Jump to content

One-side collision detection


yanliom
 Share

Recommended Posts

The problem is, that you are setting the x & y values of the player directly.

 

Arcade physics only works if you use the velocity values.

Based on the velocity, the arcade engine moves the sprites itself, and then all collisions work,

 

You (and I) may wonder, why the collision from above did still work in your example.

This is because the gravity is still on.

(Gravity sets the y velocity to a negative value, the physics collisions happen (that is why it only works on the negative y axis) and then you reset the velocities to 0, so no actual gravity is visible.)

 

The solution for you (I think you are going for a zelda style movement with no gravity right?) is:

 

1) set gravity to zero

2) instead of increasing / decreasing the player.body.x & y set the body.velocity.x / y to values like 100 (while keeping your reset to zero where it is now, so that the player stops if no key is pressed)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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