- Home /
Using a Empty GameObject "Grouper" - Won't Ignore Raycast
I have a group of AI characters grouped inside an empty Game Object. The empty Game Object is just there for organizing the hierarchy - I'll call it my "grouper". My problem comes when another AI is trying to use a raycast to confirm line of sight to an enemy. It always hits the grouper Game Object instead of the AI itself, and hence returns an object I don't care about.
I set the grouper Game Object to the "Ignore Raycast" layer (but left the AI characters in default) thinking that would fix my problem, but it did not.
Is there a way around this that I am missing?
UPDATE: This was due to an error in my code - please ignore! (Is proper etiquette to delete this now?)
Answer by tanoshimi · Jan 10, 2015 at 03:38 PM
Raycasts only hit colliders. So, unless your "grouper" object has a collider component (which it shouldn't), it won't be detected - there must be some other bug with your code.
$$anonymous$$y hierarchy looks like this:
GrouperGameObject (at root level of Hierarchy)
AIEntity1
Collider
AIEntity2
Collider
Etc
When the raycast hits AIEntity2's Collider, I wish it returned the AIEntity1 (or the Collider itself) but it doesn't, it returns the GrouperGameObject, which doesn't let me know which AIEntity I hit.
Well shoot, I just found the error in my code. Thanks for your help!