- Home /
Ignore raycast from specific object?
Okay, so I'm working on this FPS, and I have a weapon. When you shoot, the raycast for the particle emitters work fine. When you look down and shoot, it's hitting your own collider, and obviously not hitting the ground where I want. If I turn on the "Ignore Raycast" layer for my character, this works, but the enemies aren't able to hit you anymore. Is there any way I can make it so I can ignore raycasts shot by me, but not by the ones fired by the enemy?
http://dl.dropbox.com/u/2318787/Night/Night.html
Here's a rough copy of my game so far so you can see what I'm talking about.
Answer by rutter · Mar 16, 2012 at 09:57 PM
Two options come to mind.
You could use RaycastAll and return the nearest target which isn't the player.
You could set up collision layers and raycast against a layer which includes enemies, but does not include the player.
Your answer
Follow this Question
Related Questions
How to use a Raycast to see the distance traveled within a collider. 2 Answers
Move player to specific location and avoid obstacle. 2 Answers
Im trying to create a word game with a twist 0 Answers
Raycast not detecting ANY HITS AT ALL when starting inside a collider. 0 Answers
Raycast Destroy(hit.collider.gameObject); (Still need help) 1 Answer