Sign in to follow this  
RojanShrestha

Collision

Recommended Posts

RojanShrestha    124
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
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
BrianJensen    343
[quote name='newbie_gamer' timestamp='1313841064' post='4851559']
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??[b] For example In mario, player can walk on top of those after jumping on top of them..[/b] I want similar functionality. Can anyone help?
[/quote]

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
RojanShrestha    124
[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 />[/quote]<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
Serapth    6671
[quote name='newbie_gamer' timestamp='1313904157' post='4851814']
[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 />[/quote]<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
BrianJensen    343
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this