- Home /
How to tell if your touching the side of the ground or platform
How can I check if your touching the side or the top o a platform? In my game you can swing your sword down to bounce of the side of a wall to bounce off, but since i dont know how to check if you touched the side or the top, i had orginized it so that i have two tilemaps, one for the wall and one for the floor but this solution causes other problems
Answer by sacredgeometry · Dec 05, 2021 at 01:32 AM
There are a few ways to check: This video covers 3 of them. But in short depending on the game, collision, raycasting down, sphere cast, relative position, bounds intersection etc.
There are a lot of ways, which one is best for you really depends on what you are trying to do. I think the most common approach is probably ray-casting down so you might as well start there.
raycasting down wont help. i am trying to detect if you hit a wall or a platform. if i raycast sideways cause then when the sword swings down, i can only have a small spot to detect where you can bounce off, what if you hit it will the bottom part of the sword? And i also cant raycast down cause i dont want to bounce of the ground, only the walls.
You could raycast a fan of rays couldn't you? Say at 5 or 10 degree increments up to 45 or 90 degrees in front of the player?
or as mentioned use a spherecast or collider
i already do. i use a boxcast around where the sword is to check if i hit the ground. the problem is i want it so if you swing your sword down and hit the ground (top of a platform) you dont bounce, but if you hit the wall (side of a platfrom) you do.
Your answer
Follow this Question
Related Questions
Anyone knows how to refresh tiles? 0 Answers
does unity lightwave rp work with tilemaps? 0 Answers
Generating a 2D map out of a tileset problem. Array and If statements. HELP! 0 Answers
What's better to use: Collider tilemap 2D or edge collider? 0 Answers
When my Ortho camera zooms in, it distorts/warps my 2d tilemap. How do I fix this unwanted effect? 0 Answers