Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Raycast only shooting on certain layers?

$
0
0
I'm making a Portal clone, and I have a code that is supposed to shoot only onto objects with certain layers. I start by defining the variable:

Code (CSharp):
  1. public LayerMask canShootAt;
Later in the script when I incorporate raycasting:

Code (CSharp):
  1. if(Physics.Raycast(ray, out hit, canShootAt))
  2. //The code that shoots the Portal
I created two layers: "Shootable" and "Nonshootable." I put the layer "Shootable" on the objects I want to be able to shoot onto, and...

Raycast only shooting on certain layers?

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>