Sign in to follow this  
lszanto

Box2D Colliding From 1 Direction

Recommended Posts

I'm trying to work on a game and I have an object which I only want to collide with from one direction. I'll try and illustrate my idea below ___________________ ------------------- 0 Ok say the above 'character' tries to jump. I want him to be able to jump up through the object and to not collide with the sides of the object, but rather only collide with the character when it is standing on top of the object. I hope this makes sense, if it doesn't please ask to explain further. Thanks in advance for any help, Luke

Share this post


Link to post
Share on other sites
Are your objects represented through tiles, or are they defined in objects?
It's crucial to deal with the design of the environment when working
on collision detection. There are many tutorials on colisions out there.

-What is your approach on the "level" objects of yours?

Share this post


Link to post
Share on other sites
They are just objects, that will be created randomly and as the screen moves up, a new set will be randomly generated so the screen always has blocks across it.

If it helps I am trying to make a sort of clone of doodle jump the game on the iPhone, or with the same base concept anyway.

I am considering just writing my own collision detection method and not using box2d as I don't really need it for this sort of project.

Share this post


Link to post
Share on other sites
You could just do an ordinary parametric test between a direction vector from the center of your character, and all the nearest blocks.

You could also try and render the non-passable geometry to a texture,
and sample this texture around your character, to check wether he collides
with the blocks.

If your character can jump so fast, that he may pass a block completely, in just one iteration, you should check if the line between the previous location of his solid geometry and the new location passes any solid blocks.

There are really many different approaches to this.
-I hope you find what's best for your specific application

Share this post


Link to post
Share on other sites
If you've decided not to use Box2D this won't be of much use to you, but I know that the problem you mention (the 'one-sided platform' problem) has been discussed on the Box2D forums, so you might check there to see if you can find any info on the topic. (There might even be a testbed program demonstrating how to create one-sided platforms, but without checking, I can't say for sure.)

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