Jump to content
  • Advertisement
Sign in to follow this  
RojanShrestha

Collision

This topic is 2555 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a Bounding box collision setup in my code and it works fine but now I want my player to walk on top of the other sprites. How do I do that?? For example In mario, player can walk on top of those after jumping on top of them.. I want similar functionality. Can anyone help?

Share this post


Link to post
Share on other sites
Advertisement
I've never done something like this but here's how i would do it:

create a variable to keep track of the player's altitude and number of times it crosses a bounding box
have a bounding box on the item you want to walk on top of, and if the player intersects it and gets above the item's altitude have the player have it's default altitude above that bounding box

there's probably a better way of course but this is what i came up with off the top of my head...

Share this post


Link to post
Share on other sites

I have a Bounding box collision setup in my code and it works fine but now I want my player to walk on top of the other sprites. How do I do that?? For example In mario, player can walk on top of those after jumping on top of them.. I want similar functionality. Can anyone help?


You would declare the monster as dead, but still visible displaying the dead animation. Since the monster is dead you would no longer check collision on it. Basic. Then remove the monster by declaring !visible and you're good to go.

Share this post


Link to post
Share on other sites
<br />I've never done something like this but here's how i would do it:<br /><br />create a variable to keep track of the player's altitude and number of times it crosses a bounding box<br />have a bounding box on the item you want to walk on top of, and if the player intersects it and gets above the item's altitude have the player have it's default altitude above that bounding box <br /><br />there's probably a better way of course but this is what i came up with off the top of my head...<br />
<br /><br /><br />

your method worked fine for making the player walk on top of the wall but I having trouble getting the player to fall down when the wall ends

Share this post


Link to post
Share on other sites

[quote name='mastrgamr_' timestamp='1313899662' post='4851800']<br />I've never done something like this but here's how i would do it:<br /><br />create a variable to keep track of the player's altitude and number of times it crosses a bounding box<br />have a bounding box on the item you want to walk on top of, and if the player intersects it and gets above the item's altitude have the player have it's default altitude above that bounding box <br /><br />there's probably a better way of course but this is what i came up with off the top of my head...<br />
<br /><br /><br />

your method worked fine for making the player walk on top of the wall but I having trouble getting the player to fall down when the wall ends
[/quote]

Is up a constant? One way ive seen is in the level editor storing a bitwise value for solidness. So you do something like: Left Solid?/Top Solid?/Right Solid?/Bottom Solid? = 1110, which would represent a "tile" that was solid from the left, top and right, but you could jump through from the bottom.

Share this post


Link to post
Share on other sites
Your character and every object in your game should be falling( or being pulled down constantly). Think about how it works in real life, Gravity. A constant force applied on us no matter what our collision is.

You should always check for a collision below your objects, if it isn't there apply a gravity variable to induce falling.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!