Nerd For Tech
Published in

Nerd For Tech

Raycast Ignore Trigger Colliders

Objective: Allow a Raycast to ignore trigger colliders.

Our enemy has a player detection radius that is a trigger collider. When we cast our ray from the camera to the enemy, our shot is hitting that sphere. But there is a way to ignore all trigger colliders.

When we call Physics.Raycast, we can set the fifth parameter to QueryTriggerInteraction.Ignore. The nice thing about using using method over a layer mask is that it will ignore all trigger colliders everywhere! After all, we don’t our shot to stop at other trigger colliders such as pressure plates, item pick-ups, or proximity alarms!




NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit

Recommended from Medium

The Engineering Behind the COVID-19 Chatbot at Telegram

The Mystery of Event Dispatching in Cizen

Spark partitioning: full control

Android vs iOS: Which Platform is Right For Mobile App Development?

Why so Kubernetes?

hp service centre near me

Classes and Objects — Java

Using Flexera One Automation for FinOps at Flexera

A piggy bank with a coin in the slot and more spread below it

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ryan Sweigart

Ryan Sweigart

An independent Unity Developer.

More from Medium

Depth with Unity TileMaps

Indy Pro ’22: IWTV

Unity: Create your own Wordle in under 24 hours

👾 Teaching the Game Loop