So, I’m making a grid based game that the player views from a first person perspective. I’ve decided to use the Tilemap system in a 3D space to make level creation easy, but I’ve run into a little snag. For some reason, all of my attempts to detect the walls in my game haven’t worked.
I’m using the Tilemap collider as an easy way to detect collisions with immovable objects however, I’m unable to get my Raycast to interact with them. My Raycast just never reacts to the collider.
I’ve made sure that the Raycast was getting fired from the correct location, and I’ve even made sure it was firing in the right direction. I even tried firing the Raycast in many different directions just to make sure I had the direction right, and none of them hit anything.
Although, I did try placing a cube below the floor to see if the raycast could see it, and it did! That means that the Raycast is ignoring the Tilemap collider while still interacting with other objects.
So my question is this, am I doing something wrong, or were Raycasts just never designed to work with the Tilemap collider system while in a 3D space?
If it’s the former, I’d highly appreciate some guidance into how I might fix this problem. It it happens to be the latter, could someone please help me with figuring out an alternate solution?
Incase it helps, I’ll post the code that I’m using for the Raycast below,
CollisionCheck.transform.Translate(MoveDir.x, MoveDir.y, 0);
if (Physics.Raycast(CollisionCheck.transform.position, Vector3.forward, out ColInfo))
//Something is ahead of the player, so interact with it! (Currently it's just walls, so it'll just stop player movement.)
IsBusy = false;
If there’s anything else you need to know to help, I’ll happily answer any questions.