Quantcast
Channel: Latest Questions by vptb
Viewing all articles
Browse latest Browse all 18

Raycast ignore itself

$
0
0
I've worked with Raycasts for a long time now, and I understand how it works with layermasks, etc... But I have a problem right now that I couldn't find in any question here. Let's say I have a sentry gun on a 2D game, which is rotating over time searching for the player. Each frame it tests with a raycast if it sees the player. This raycast is ignoring everything except the layer "Obstacle" which is used on objects which the player can't go through (It's a tile based game). The objects with that layer are the level walls, but also some "traps", and the sentry gun is one of them. So my problem right now is that I want to shoot a raycast from the sentry gun, but the raycast is hitting the sentry itself, and I can't create a layer for all the obstacle "traps" and shoot a raycast ignoring everything except that layer because that way the player wouldn't be able to hide himself from sentrys behind other kind of "traps". So right now I'm searching for a way of having a raycast ignore everything except 1 layer, and also ignore 1 object inside that layer. PS: I know that I can use RaycastAll and then ignore this collider, but I am looking for a more efficient way if it exists.

Viewing all articles
Browse latest Browse all 18

Trending Articles



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