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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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