Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Herman-Tulleken · Oct 15, 2010 at 09:11 AM · raycasttrigger

Can I make SphereCast work with triggers?

It seems that SphereCast won't cast against triggers (even though RayCast does...)

Is there any way that I can make them work with triggers? (Maybe a layer setting or something; I am hoping here!)

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TaintedLemon · Aug 05, 2011 at 04:28 AM 0
Share

I also have this problem. Extremely frustrating because I need to use triggers as colliders are too inefficient.

avatar image Straafe · Oct 27, 2012 at 10:17 PM 0
Share

I also have this problem... anybody have an alternative method??

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Matou · Apr 01, 2014 at 09:46 AM

A bit late maybe, but it seems that there is a workaround:

  1. create a new child object under your trigger object

  2. add a collider to the child object that has the exact same shape as the trigger

  3. create a new layer mask (let's say "ColliderCast") and set this layer mask on the child collider

  4. go to the Edit -> Project Settings
    • Physics Panel

  5. disable all collisions on the "ColliderCast" layer mask.

Thus, nothing will collide with a "ColliderCast" object so this new collider shouldn't change the behavior of other objects passing through.

However the sphereCast should collide with it, because it's a collider and not a trigger (except if you filter the "ColliderCast" layer mask). It seems to work for me.

Hope that helps. Peace :)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image _Prism_ · May 24, 2016 at 01:01 PM 0
Share

This is a great answer BUT... Something to be aware of; in a game I worked on, I ran into issues when the "ColliderCast" collider was the exact same size as the trigger collider. After a lot of investigation (announcement debugs) I found that the weapons that used Raycasts (projectile weapons) where registering against the "ColliderCast" (used to register melee attacks). This is in spite of the box for Gun/$$anonymous$$elee being unchecked - objects on either of these layers should be completely unaware of each other.

I shrank one of the colliders by 0.1 of a unit and have never had the same false register since. It doesn't seem to matter whether it's the trigger or non-trigger collider.

BTW, I know this sounds illogical, I spent an hour trying to prove myself wrong; but I can recreate the "false positive" with 100% success and fix it 100% by ensuring at least some size difference between the colliders.

avatar image
0

Answer by lil_billy · Oct 27, 2012 at 11:42 PM

sorry, but no the reference says you cant

however you could try a more complicated version of raycast like having a common center and shooting a bunch of rays from it in different directions or if you are using raycast in an update (which i dont recommend) you could lerp the direction to essentially create a sphere.

though doing it that way, i can't foresee it being particularly useful because of how inefficeint it is good luck

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Straafe · Oct 27, 2012 at 11:43 PM 0
Share

$$anonymous$$y goal is to simply give units a "range" in which they can detect other units around them (say, within 20 meters). Would OverlapSphere be the best approach?

avatar image lil_billy · Oct 28, 2012 at 12:24 AM 0
Share

ive heard that triggers can detect triggers if both objects have a rigidbody but on that if all you want to do is have a range in which to detect an enemy unit, you dont need to detect the enemy units range you can simply make the range to detect the unit surely your unit is using a solid collider

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

DontGoThroughThings vs Triggers 1 Answer

Raycast not updating inside a trigger collider 0 Answers

How do I detect if there's an object at the same position and destroy ONLY ONE of them? 1 Answer

Box Collider wont trigger a Trigger after moveing the object 0 Answers

Raycast hits a collider and halts. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges