- Home /
Raycast layer problem
so in the following code my raycast will not hit anything....however if I remove that '8'which is the layer number it will work perfectly....only it will collide with every object on screen:`
if(Physics2D.Raycast(touchpos,Vector3.forward,10000,8))
character.transform.Translate(Vector2.right*speed*Time.deltaTime);`
so if someone could tell me whats wrong with my layers, or maybe my code thx in advance
I tend to set the layer mask up as a public var, which will create a drop down list in the inspector for this script. Select what I want in the mask here, then use that var in my raycast.
Your answer
Follow this Question
Related Questions
Change multiple object layers 0 Answers
Raycast Having Pointless Errors 1 Answer
Raycast not working ? 1 Answer
Detecting that I'm clicking a unit even though I'm not? 0 Answers
Why does Layer Masking for Raycasts only work on Layer 8? 1 Answer