Raycast doesn't interact with Tilemap Collider when in a 3D scene.
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,
RaycastHit ColInfo;
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.)
Debug.Log(ColInfo.transform.name);
IsBusy = false;
}
else
{
StartCoroutine("LerpCRT");
}
If there's anything else you need to know to help, I'll happily answer any questions.
Your answer
![](https://koobas.hobune.stream/wayback/20220613005916im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Still constant jumping even with raycasting. 0 Answers
Bounds and extents of a tilemap collider across differing y axes, Tilemap collider bounds 0 Answers
C# Door Script Problem 0 Answers
I want ray cast in 4 directions, instead i am getting this. 1 Answer
problem with tilemap collider and composite collider 1 Answer