Hi,
I read up on all the collision detection questions that have been previously posted. None of them addresses my issue, and a lot of the code samples supplied to solve issues are more complicated than I understand.
I am working on an a simple 2D shooter game, set up sort of Mario style. My character has an issue that I cannot resolve, and I was hoping one of you might have a tidbit stuck somewhere in those brilliant heads of yours that could help me out.
The basic issue is collision detection. Everything in my game works except this one thing, and I cannot figure it out. I think I need an function to override the player/tiles collision, but everything I try does not work. The player is bleeding into the next tile and then auto-jumping on top of it, instead of stopping because the tile is blocking its path.
The above image shows two tiles, and a player. The player is moving in the direction of the arrow. When the back side of the players personal space reaches the front of tile 1, the player jumps up on to tile two automatically.
Or......
If there is no tile two, the player will bleed ¾ into tile 1 then jump up on to tile 1.
In both cases, the player should dead STOP at before passing tile 1 and be unable to proceed unless the jump button is tapped. Can you help me with a simple function that will resolve this issue?
Thank you.
CO
Newbie Collision Detection question
Re: Newbie Collision Detection question
Are you using a library for the collision detection or did you code it yourself? Best would be, if you could post a minimal example in a .love file, so we can reproduce it ourselves.
Check out my blog on gamedev
Re: Newbie Collision Detection question
If your player bleeds halfway into your tiles, are you sure you are doing the coordinates correctly? Images are drawn on their topleft corner, but by default most collision libraries and functions work from the center. This can cause things to register collisions incorrectly because the collision library thinks the object is in a different location than it really is.
Re: Newbie Collision Detection question
Actually Plu, you may be on to something. Let me comb over my code to see. I have been blaming my character settings, but perhaps it is my tile settings that are the culprit. Thanks for the idea.
Re: Newbie Collision Detection question
Micha, I used some starter code and modified it to fit my situation.
- JovialFeline
- Prole
- Posts: 28
- Joined: Wed Jan 08, 2014 2:32 pm
Re: Newbie Collision Detection question
I think the first problem is largely tied to your second. In your first problem, Tile #1 is resolving its collision with the player by moving them to its right and then tile #2 resolves its collision by moving the player upward.
Something about your collision detection is off. Your tiles are reading the player's position differently than you're expecting (or perhaps vice versa). Problem #2 hints the tile is seeing the player inside its bounds when he tries to walk off. Once you can get the player to stop "bleeding" into tiles, the only thing you should have to worry about is resolving a player landing from a jump onto the overlap between two tiles. You might see a recurrence of problem #1 in that case.
Any chance we could see the collision code?
Something about your collision detection is off. Your tiles are reading the player's position differently than you're expecting (or perhaps vice versa). Problem #2 hints the tile is seeing the player inside its bounds when he tries to walk off. Once you can get the player to stop "bleeding" into tiles, the only thing you should have to worry about is resolving a player landing from a jump onto the overlap between two tiles. You might see a recurrence of problem #1 in that case.
Any chance we could see the collision code?
Who is online
Users browsing this forum: Bing [Bot] and 1 guest