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
0
Question by Andrew_Kenady · Feb 18, 2014 at 09:13 PM · collisioncolliderlistontriggerenteraccess

Accessing a collider's collisions without OnTriggerEnter or OnTriggerStay

Hello! We've been trying to find an answer to this for a while now, and simply can't seem to find a solution. Is there a way to access a specific collider's list of active collisions without attaching a script to the specific collider and implementing the OnTrigger methods?

Basically, we'd like to be able to have a single Enemy class that has collision bounds for chasing, attacking, and damaging the player. The only way we've been able to get this to work is by creating 3 different children objects, each with its own collider and script. The script implements OnTriggerEnter and OnTriggerExit to set a boolean for whether or not the player is inside the bounds.

This is great and all, but we'd really like to be able to just have the main enemy class reference 3 Collider objects and check them manually for collisions with the player. Is there some sort of method that would work like "Collision[] Collider.GetCollisions()"? From what we've been able to find, the only way to detect collisions is by making a script with the "OnTrigger" methods. Is there no way to manually check for all collisions on a collider?

Thanks in advance!

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 iHaveReturnd · Feb 18, 2014 at 09:21 PM 0
Share

I'm having a hard time understanding what you are trying to accomplish by manually checking for the collisions... The trigger events only fire when that event occurs, otherwise there would be no change in the triggering events or collision. You can just use booleans like you were to keep track of the current state if you need the state of the collision.

$$anonymous$$aybe elaborate on what you are trying to accomplish some? From the sound of it right now, the manual checks would be unnecessary.

avatar image Andrew_Kenady · Feb 18, 2014 at 09:26 PM 0
Share

Well, the idea is that with manual checks to the colliders, we wouldn't have to have the extra class to keep track of collisions. In addition, "OnTriggerEnter" isn't called if the object is disabled and then enabled within the collision bounds, and "OnTriggerExit" is not called when the targeted object is destroyed while within the collision bounds. Basically, we're looking for a more efficient and accurate way of checking whether or not the player is in the trigger.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by getyour411 · Feb 18, 2014 at 10:51 PM

You might want to look at physics.overlapsphere, spherecast/all and similar options. Not sure I get what you are after but after first read its what came to mind:

https://docs.unity3d.com/Documentation/ScriptReference/Physics.html

It's semantics but the title and text talk alot about collisions but OnTrigger___ doesn't have real collision data.

Edit: marking as Answer

Comment
Add comment · 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

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

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

onTriggerEnter dosent work 2 Answers

A node in a childnode? 1 Answer

simple onCollision and onTrigger problem 1 Answer

OnTriggerEnter() and OnCollisionEnter(), OnControllerColliderHit() not working with character controller 2 Answers

OnTriggerEnter and GUIText problem 0 Answers


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