- Home /
How do I access the exact tile my player is colliding with?,How can i get access to the specific tile my player is colliding with?
I'm making a 2d platforming game where I'm trying to get the type of tile my player is colliding with when they dash so I can bounce the player accordingly. I'm trying to access a specific tile from my tilemap that has a tilemap collider 2d on it. The picture I attached is from my playerController script. direction != 0 is just how I know that the player is dashing. I know that what I did isn't working because I don't know how to get the exact coordinates where the dash is happening and instead am using my rigid body position. I'm pretty sure that this is resulting in me always saving a tile adjacent to the tile I am actually trying to get in my colllisionTile variable. When I run into this and dash into a tile with a collider on it I just get a null reference exception on by Debug.Log line. I'm new to unity and scripting so go easy on me and thanks in advance for any help :) ,I'm making a 2d platformer where I want to be able to access the type of tile the player is colliding with when he does a dash so that I can change the player's velocity accordingly. The picture I attached is from my playerController script. direction != 0 is just how I know a dash is happening. I know that what I'm doing isn't right though. I don't know how to get the coordinates of where the exact collision is happening so I'm just getting the position of my player's rigid body but I'm pretty sure this is always getting me a tile adjacent to the tile that I'm actually colliding with. Currently when I run this it just gives me a null reference exception on the Debug.Log line. I'm new to unity and scripting so go easy on me. Thanks in advance!
Your answer
Follow this Question
Related Questions
Collision/scripting for tiles 0 Answers
How can I achieve movement on hextile? 0 Answers
TileMap won't show up in 2d object in heirarchy. 0 Answers
Unity 2D TileMap Rule Tile Carpet 1 Answer
Find Tilemap Player is Currently At 0 Answers