Archived

This topic is now archived and is closed to further replies.

Neen10do

platform collision detection

Recommended Posts

Neen10do    122
ive searched on the form, but i cant find a question that addresses what i need. i need to create collision detection (reaction) that allows my player to jump through the platform (up through it) but when comming back down his feet land on it. i have my collision detection working , but its teh reactions. if i only test it when the player is falling, if his head is touching the platform it would move him, and i dont want this. any ideas? ---------------------- i code therefore i am. Aero DX - Coming to a bored Monitor near you!

Share this post


Link to post
Share on other sites
starstriker1    245
I''d think that you''d only test for collision with the specific platform when you have a downwards velocity. That should work...

And to get rid of the problem you mentioned, just make it so the head is not given a collision test when the velocity is downward.

Did I help?

Share this post


Link to post
Share on other sites
Neen10do    122
regaurdless of what bounding box i do on the character, it is possible that if he doesn''t reach the top of the platform (its a 20*20 tile) and he starts to fall, that it would render a collision and put him on the platform when he obviously did not reach it. obviously this problem has been address by people before, how did you guys do it?

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!

Share this post


Link to post
Share on other sites
starstriker1    245
His head is whats getting got in the scenario you mentioned, right?

Then make it so that the head is not considered when the character is falling.

Maybe your not being clear?

Share this post


Link to post
Share on other sites
j_som_i_jonas    122
I think that you have to limit the collision test to the soles of the feet, otherwise you run the risk of the player getting trapped inside a platform if the jump wasn''t high enough to get the feet above the plaform, but high enough to trigger a platform collision on returning down.

However, you will still end up having to formulate a strategy for all events where a collision occurs while you are inside some object. For example:

(1) if the feet are not level when jumping, one foot might be over the platform, the other might still be in the middle of it.

(2) platforms might not be level, or there might be obstacles placed on the platform. You might be over the platform but not outside of the object.

Have you seen any games that use the technique you''re asking about? If so, how do they handle the above situations?


Regards,

jonas

Share this post


Link to post
Share on other sites
m_wherrett    122
When your player intersects with a platform I''m guessing your code will detect this and place them nicely on top of that platform. Ok? You''re problem is that you want them to be able to jump upwards through the platform and then land on top of it.

There are two steps needed for this and the first one has already been mentioned.

1. Ensure the collision code checks if the player is moving up or down. If they are moving upwards, don''t bother placing them on the top of the platform.

2. The second step addresses a less obvious problem. If the player jumps up halfway through the platform and then begins to fall they will warp up to the top of the platform. I''m assuming your world is tile based so I suggest you try the following. Keep a record of the last tile the player was in. So as the player moves from one tile to the next keep a pointer to the previous one.

Now, just like you did with checking velocities, you can check if the player collided with the platform from above or below. If their previous position was below, or even to the side, you can ignore the code that twats them on top of that platform.

If that aint clear just say so.

Share this post


Link to post
Share on other sites
Neen10do    122
thats pretty clear, and thats what i ended up doing, having a value passed in that was the last y position, and if it was above ( a smaller value in this case), then make sure that the bottom of the bounding box is in between the tiles (to keep his head from side-swiping the tiles). and right now his feet can still side swipe the tiles, but i plan on fixing that.

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!

Share this post


Link to post
Share on other sites