Skip to main content
Post Closed as "Duplicate" by Anko, CommunityBot
Clearer title. Condensed. Introduced paragraphs, fixed grammar.
Source Link
Anko
  • 13.5k
  • 10
  • 56
  • 82

Java platformer using Tiled maps How do I detect a tile map collision's direction?

So here is the deal. I've been working on and off on my little platformer and im at the point forI'm implementing collision detection with the map for my platformer. I have a method that generates a polygon on every tile and checks if the player hits it it's-- that's all fine there. But theThe problem is that when ever a player touches a wall in front of him the Dd key wichwhich moves him to the front gets disabled so he can't walk any further that way. this

This method works great for preventing him to walkfrom walking into walls, but iI also want him to be able to jump on the walls and there is the problem. So he falls on the tile(polygon) the game senses that and applies the same method for the dd key thus, preventing the character to walkfrom walking left or right, because the game thinks it is hitting the tile in the front but iit is hitting from above (i'm sorry a little vague i'm not good at english). 

Long story short, the gamesgame handles collision from the top theabove same as collisions from the front or back because i don't have an idea how to make a method that would. How do I make it able to recognizerecognise collisions from the top or side. i hope you guys can help if further explantion is needed please ask. Thank you! separately from above?

This is myMy code i don't have directly acces to it but it is along thethese lines of this:

if(PlayerPolygon.interesects(TiledPolygon) && dKey==1) { moveX = 0; } if(dKey==1) { player.x +=moveX } 

Java platformer using Tiled maps

So here is the deal. I've been working on and off on my little platformer and im at the point for collision detection with the map. I have a method that generates a polygon on every tile and checks if the player hits it it's all fine there. But the problem is that when ever a player touches a wall in front of him the D key wich moves him to the front gets disabled so he can't walk any further that way. this method works great for preventing him to walk into walls but i also want him to be able to jump on the walls and there is the problem. So he falls on the tile(polygon) the game senses that and applies the same method for the d key thus preventing the character to walk left or right because the game thinks it is hitting the tile in the front but i is hitting from above (i'm sorry a little vague i'm not good at english). Long story short the games handles collision from the top the same as collisions from front or back because i don't have an idea how to make a method that would make it able to recognize collisions from the top or side. i hope you guys can help if further explantion is needed please ask. Thank you!

This is my code i don't have directly acces to it but it is along the lines of this

if(PlayerPolygon.interesects(TiledPolygon) && dKey==1) { moveX = 0; } if(dKey==1) { player.x +=moveX } 

How do I detect a tile map collision's direction?

I'm implementing collision detection with the map for my platformer. I have a method that generates a polygon on every tile and checks if the player hits it -- that's all fine. The problem is that when ever a player touches a wall in front of him the d key which moves him to the front gets disabled so he can't walk any further that way.

This method works great for preventing him from walking into walls, but I also want him to be able to jump on the walls and there is the problem. So he falls on the tile(polygon) the game senses that and applies the same method for the d key, preventing the character from walking left or right, because the game thinks it is hitting the tile in the front but it is hitting from above. 

Long story short, the game handles collision from above same as from the front or back. How do I make it recognise collisions from the side separately from above?

My code is along these lines:

if(PlayerPolygon.interesects(TiledPolygon) && dKey==1) { moveX = 0; } if(dKey==1) { player.x +=moveX } 
Tweeted twitter.com/#!/StackGameDev/status/387052446704762880
added 44 characters in body
Source Link

So here is the deal. I've been working on and off on my little platformer and im at the point for collision detection with the map. I have a method that generates a polygon on every tile and checks if the player hits it it's all fine there. But the problem is that when ever a player touches a wall in front of him the D key wich moves him to the front gets disabled so he can't walk any further that way. this method works great for preventing him to walk into walls but i also want him to be able to jump on the walls and there is the problem. So he falls on the tile(polygon) the game senses that and applies the same method for the d key thus preventing the character to walk left or right because the game thinks it is hitting the tile in the front but i is hitting from above (i'm sorry a little vague i'm not good at english). Long story short the games handles collision from the top the same as collisions from front or back because i don't have an idea how to make a method that would make it able to recognize collisions from the top or side. i hope you guys can help if further explantion is needed please ask. Thank you!

This is my code i don't have directly acces to it but it is along the lines of this

if(PlayerPolygon.interesects(TiledPolygon) && dKey==1) { moveX = 0; } if(dKey==1) { player.x +=moveX } 

So here is the deal. I've been working on and off on my little platformer and im at the point for collision detection with the map. I have a method that generates a polygon on every tile and checks if the player hits it it's all fine there. But the problem is that when ever a player touches a wall in front of him the D key wich moves him to the front gets disabled so he can't walk any further that way. this method works great for preventing him to walk into walls but i also want him to be able to jump on the walls and there is the problem. So he falls on the tile(polygon) the game senses that and applies the same method for the d key thus preventing the character to walk left or right because the game thinks it is hitting the tile in the front but i is hitting from above (i'm sorry a little vague i'm not good at english). Long story short the games handles collision from the top the same as collisions from front or back because i don't have an idea how to make a method that would make it able to recognize collisions from the top or side. i hope you guys can help if further explantion is needed please ask. Thank you!

This is my code i don't have directly acces to it but it is along the lines of this

if(PlayerPolygon.interesects(TiledPolygon) && dKey==1) { moveX = 0; } 

So here is the deal. I've been working on and off on my little platformer and im at the point for collision detection with the map. I have a method that generates a polygon on every tile and checks if the player hits it it's all fine there. But the problem is that when ever a player touches a wall in front of him the D key wich moves him to the front gets disabled so he can't walk any further that way. this method works great for preventing him to walk into walls but i also want him to be able to jump on the walls and there is the problem. So he falls on the tile(polygon) the game senses that and applies the same method for the d key thus preventing the character to walk left or right because the game thinks it is hitting the tile in the front but i is hitting from above (i'm sorry a little vague i'm not good at english). Long story short the games handles collision from the top the same as collisions from front or back because i don't have an idea how to make a method that would make it able to recognize collisions from the top or side. i hope you guys can help if further explantion is needed please ask. Thank you!

This is my code i don't have directly acces to it but it is along the lines of this

if(PlayerPolygon.interesects(TiledPolygon) && dKey==1) { moveX = 0; } if(dKey==1) { player.x +=moveX } 
added 193 characters in body
Source Link

So here is the deal. I've been working on and off on my little platformer and im at the point for collision detection with the map. I have a method that generates a polygon on every tile and checks if the player hits it it's all fine there. But the problem is that when ever a player touches a wall in front of him the D key wich moves him to the front gets disabled so he can't walk any further that way. this method works great for preventing him to walk into walls but i also want him to be able to jump on the walls and there is the problem. So he falls on the tile(polygon) the game senses that and applies the same method for the d key thus preventing the character to walk left or right because the game thinks it is hitting the tile in the front but i is hitting from above (i'm sorry a little vague i'm not good at english). Long story short the games handles collision from the top the same as collisions from front or back because i don't have an idea how to make a method that would make it able to recognize collisions from the top or side. i hope you guys can help if further explantion is needed please ask. Thank you!

This is my code i don't have directly acces to it but it is along the lines of this

if(PlayerPolygon.interesects(TiledPolygon) && dKey==1) { moveX = 0; } 

So here is the deal. I've been working on and off on my little platformer and im at the point for collision detection with the map. I have a method that generates a polygon on every tile and checks if the player hits it it's all fine there. But the problem is that when ever a player touches a wall in front of him the D key wich moves him to the front gets disabled so he can't walk any further that way. this method works great for preventing him to walk into walls but i also want him to be able to jump on the walls and there is the problem. So he falls on the tile(polygon) the game senses that and applies the same method for the d key thus preventing the character to walk left or right because the game thinks it is hitting the tile in the front but i is hitting from above (i'm sorry a little vague i'm not good at english). Long story short the games handles collision from the top the same as collisions from front or back because i don't have an idea how to make a method that would make it able to recognize collisions from the top or side. i hope you guys can help if further explantion is needed please ask. Thank you!

So here is the deal. I've been working on and off on my little platformer and im at the point for collision detection with the map. I have a method that generates a polygon on every tile and checks if the player hits it it's all fine there. But the problem is that when ever a player touches a wall in front of him the D key wich moves him to the front gets disabled so he can't walk any further that way. this method works great for preventing him to walk into walls but i also want him to be able to jump on the walls and there is the problem. So he falls on the tile(polygon) the game senses that and applies the same method for the d key thus preventing the character to walk left or right because the game thinks it is hitting the tile in the front but i is hitting from above (i'm sorry a little vague i'm not good at english). Long story short the games handles collision from the top the same as collisions from front or back because i don't have an idea how to make a method that would make it able to recognize collisions from the top or side. i hope you guys can help if further explantion is needed please ask. Thank you!

This is my code i don't have directly acces to it but it is along the lines of this

if(PlayerPolygon.interesects(TiledPolygon) && dKey==1) { moveX = 0; } 
Source Link
Loading