Timeline for How to handle Tilemap Collision with only the character's lower body, while the head is allowed to overlap tiles above?
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 24, 2022 at 10:28 | comment | added | Samuel Slade | It was more for experimentation and learning - recreating the behaviour from the original Pokemon games. I'm working on another project without tile-based movement, but it would be good to understand the mechanics properly here. If you could provide a second answer specific to the tile-based movement and the best way to approach that, then that would be appreciated. I did manage to solve it using this approach gamedev.stackexchange.com/a/198809/8792 but that might not be the best way, so I'm open to alternatives | |
| Jan 19, 2022 at 11:39 | comment | added | Philipp | @SamuelSlade Do you seriously want tile-by-tile movement? Unity is much better at handling movement in an analog manner. But if you insist, then I would recommend to not deal with Collider2Ds and Physics2D at all and just query the Tilemap to see if there is a blocking tile at the destination. Want me to write another answer to explain the details? | |
| Jan 19, 2022 at 10:42 | comment | added | Samuel Slade | Another issue I have found with this, that I did actually encounter when using transform.position = ... (I assume it will still occur with the MovePosition you suggested), is: because I'm setting the target position as the next tile, then my logic checks on each frame update if I've reached that target yet. If not, it continues to try to move and doesn't check for further input until I'm closer (as I don't want to allow direction switching mid-move). Following your answer, the player would get stuck constantly walking into a wall. Any suggestions to get around that? | |
| Jan 17, 2022 at 15:16 | comment | added | Samuel Slade | It sounds like this could have worked, as my logic would have tried to move to the next tile, but would have been physically blocked by the engine. However, I suppose it could have a problem if the tilemap collider's bounds didn't exactly align to the grid (in that the player could end up moving slightly closer to the next tile). | |
| Jan 11, 2022 at 15:27 | history | edited | Philipp | CC BY-SA 4.0 | added 106 characters in body |
| Jan 11, 2022 at 15:21 | history | answered | Philipp | CC BY-SA 4.0 |