- Home /
ignore raycast layers problem
Is it possible to make another layer than the "IgnoreRaycast" layer ignore raycasts? If not, here is my problem:
It is a topdown game. The Player is a Plane. This playerplane needs to be ignored by raycasts, because under the player can be objects with OnMouse functions. So i put the player in the IgnoreRaycast layer.
If the player goes to a lower level of a building the renderers of the upper layer get disabled by script, and the layer of the renderers gets changed (to IgnoreRaycast).
Here comes the problem: A ray from the camera checks if the player is visable.
So the players and the hidden upper floors need to be in the IgnoreRaycast layer because of the OnMouse functions under them. But the ray from the camera needs to recognize the IgnoreRaycast layer, to see if the ray hit the player.
But that means the camera ray also recognizes the hidden upper floors and tells the script the player is not visable, even if he is.
I cant disable the collider of the hidden upper floor, enemies and physic objects would fall down.
If i could create another layer that behaves exactly as the IgnoreRaycast layer, but has a different name, i could let the camera ray ignore this other layer and put the hidden upper floors in this layer.
Any ideas how to do this or solve the problem in another way?
Answer by meat5000 · Oct 10, 2013 at 06:28 PM
Put a layermask in your raycast. This determines which layers are used in the raycast to the exclusion of all others.
yes i do that, but the problem is that i cant use a layermask with On$$anonymous$$ouse functions