I wrote my codes like this,
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
var distanceInfi = Mathf.Infinity;
if(Event.current.type==EventType.MouseDown){
if (Physics.Raycast (ray, hit, distanceInfi,8)) {
firstPosition = hit.point;
print(firstPosition);
}
}
Also,I found that there is an argument named “layermask” in function “Physics.Raycast()”, so I set number 8 in my code according to my creating plane’s layer is “user layer 8” .
But, there is no output,I don’t know why? Is there any problem?
Layermask is not the number of the layer used but rather a bitfield made of different layer. Check the documentation for more details.
If you want to use the layer 8 inside your mask, use this code instead:
LayerMask mask = 1 << 8;
http://unity3d.com/support/documentation/Components/Layers.html