- Home /
Why is my raycast returning true to a wall collision that isn't there?
I'm making a 2d game with 3d objects. I have a raycast facing towards the camera for a wall layer. I also have another raycast facing away from the camera to do the same for walls on that side. However, the raycast detecting walls towards the camera returns true when there is a wall behind it for some reason. It shouldn't return true since the raycast direction is not colliding with any wall.
Here is the raycast code.

Answer by unity_5UuMRw312fOSgQ · Jan 10, 2021 at 02:52 AM
In my experience 2D functions and 3D vectors normally doesn't work very good, since you said you are using 3D objects to make a 2D game, would it be possible to use regular Physics.Raycast instead?
Your answer
Follow this Question
Related Questions
Bullet collision help 1 Answer
How do I use Raycasting to return gameobject 2 Answers
Ray Detecting without colliders 1 Answer
Raycast hits trigger 3 Answers
2.5D Shooting Rigidbodies vs RayCasts 0 Answers