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
1
Question by Aubrey Hesselgren · Nov 27, 2010 at 08:04 PM · physicscollidersontriggerenterontriggerstay

OnTriggerEnter 's Not called at startup?

Problem: say you have two triggers overlapping one another when a scene first starts. How would you check if they're touching/overlapping without using OnTriggerStay?

(My reason to want to do this is because I am just trying to keep a track of what objects are currently near/touching one another in a list. Touching objects are added to the list in OnTriggerEnter, and removed in OnTriggerStay. That way I can use that list when I need it, and not be constantly updating).

I.e. ideally, we'd get at least one call of OnTriggerEnter if triggers are overlapping on startup.

Are there any easy work-arounds?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by TheokieZA · Nov 27, 2010 at 08:13 PM

Cant you yield the call?

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 Aubrey Hesselgren · Nov 27, 2010 at 09:02 PM 0
Share

I'm not sure what you mean?

I'm kind of counting on the physics engine to tell me which triggers are actually touching.

avatar image
0

Answer by Aubrey Hesselgren · Nov 27, 2010 at 11:48 PM

Huge hack, but I got around it by recording transform.position into a member variable "startPos" in Awake(), setting transform.position to transform.position + Random.insideUnitSphere * 1000.0f;

And then in Start() I did rigidbody.MovePosition(startPos);

That forces it to consider where it's moving to and triggers off the OnTriggerEnter call.

Also had to make sure that interpolation was off for that frame so that it just jumps straight to the first position, rather than colliding with anything inbetween (which happened because I have two of these dudes overlapping).

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

No one has followed this question yet.

Related Questions

Newbie having problems with attaching cloth to a character. PLEASE HELP! 1 Answer

OnTriggerEnter/Exit not working 1 Answer

OnTriggerEnter Multiple Collisions Activating. I tried many variations, Please help (Java) 3 Answers

How do I switch from Character player to Airship Vehicle using triggers? 0 Answers

Copy/Clone collider to other gameobject at runtime 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