- Home /
Best way to ignore y component for certain collisions?
I have a sort of top-down shooter game I'm working on, so for the bullets' collision I only want to check for x and z positions and ignore the y. An obvious way to do this would be to make all the colliders really tall so they will always hit regardless of y, but I also need to use those colliders for physics collisions.
$$anonymous$$aybe you can try different colliders in different layers. How are your "bullets" colliding?
Is it possible to have multiple colliders on the same object? The bullets are just using box colliders.
no but you can add collider in its child objects. I agree you should layers .. may you give us more information?
Actually, you can have multiple colliders in newer versions of Unity. I forget when they added it, but it definitely works as of 4.3. However, all colliders will be on whatever layer the game object is set to.
The only elegant way of achieving what you're talking about, I think, is by perfor$$anonymous$$g a sphere cast or something along the y axis during fixed update.
Answer by ankush_Kushwaha · Jan 21, 2014 at 06:33 AM
You can add another child game object to you existing game object. And add a collider into new child object. And mark the new collider as IsTrigger. And use IsTriggerEnter()
to detect the bullet collision. By using IsTriger your new child game objects will not be able to collide physically with other collider
This is how I ended up doing it. $$anonymous$$ind of annoying having to add a child object just for a collider, but it's working.