So, im making a platformer game, and im using tilemap to create levels.
And for some reason, the player object is colliding with a surface that has a normal vector (1,0,0) or (-1,0,0),even when the player is on floor and theres no
And the same problem for the wall, when the player is colliding with the wall, it collide with a surface that are like floor,even when theres no floor.
I’ve found some way to make the player able to move on the floor, but they still climbing on the wall like some spiders.
I’ve tried to take the script from the Platformer sample and put it in my project, but it doesnt work.
This happens when a sprite moves across tile boundaries because the tile collision objects aren’t one continuous shape but are instead made up of small, tile-sized pieces. As the sprite moves over these boundaries, it catches on them.
The way I’ve handled this before is by checking the position of the collision. For example, if your tile grid starts at position 0,0 and the tiles are 32x32, ghost collisions will usually occur near each multiple of 32. If the collision’s x or y is close to that, I send out a raycast to double-check its status (based on the normal) and then decide whether to discard or use it.
So if detecting a collision on the right and its very close to the tile boundary, send a ray cast a little higher up. if this fails to collide with anything you know its a ghost and can ignore it.
Another option is to skip contact point collisions entirely and create a custom collision system for the main sprite using raycasts. If this is of interest, look at britzl/platypus: Defold platformer engine.
For my platform game, I started with contact point collision, added measures to prevent ghost collisions, but eventually—much later in development—switched to a custom raycast approach for the main sprite. Britzl’s method for handling moving platforms proved extremely useful in my implementation.