Jump to content

Collision question


zxxz
 Share

Recommended Posts

Hello, 

 

I have created a platform game where the main character can run in front of crates and then jump up to land on top of them as seen in Mario etc. I have tried setting the relevant tiles to only collide on the top face, however this leads to the main character getting sucked up on top of the crate whenever any part of his body collides with the top of the crate. So if you are stood in front of the crate, jump, half of the body goes through the top of the crate as expected before the sprite is pushed on top of the crate. 

 

I have tried a few ways of getting around this such as changing the collision of the crate tiles, judging on whether the bottom of the sprite is above the crate but have not managed to get this working. 

 

Any help would be appreciated, cheers!

Link to comment
Share on other sites

There is:

body.blocked.up = false;

That means that it will be set to false and you can pass under. Place it in update so its constantly reminded that you can pass through. I've seen that example used somewhere but can't remember the link.

Just set the collision as standard on the blocks.

map.setCollisionBetween(1,10); //eg

Hope this is helpful :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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