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 SirBoboHobo · Apr 02, 2015 at 02:13 PM · c#cameratriggerobjectplatformer

check if there are no object inside a trigger

I've got Quad attached to the camera and is above it, with a mesh Collider attached to it, I'm making a vertical platformer, and would like prefabs to be instantiated when there are no objects inside that trigger. how can i check if there are no objects in a trigger?

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 DoTA_KAMIKADzE · Apr 02, 2015 at 02:18 PM

Your objects should contain triggers as well to cooperate with other trigger, and if they do just use this:

OnTriggerStay

P.S. And just for the sake of completeness - alternatively you can always maintain sort of a "contained triggers" list yourself using this 2 functions:

OnTriggerEnter

OnTriggerExit

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 SirBoboHobo · Apr 02, 2015 at 02:37 PM 0
Share

this is good only if theres 1 object, ive got lots of object entering and exiting, i need when its completely empty or exits the highest platform. is there a way maybe to check for the platform with the highest y?

avatar image DoTA_KAMIKADzE · Apr 02, 2015 at 03:43 PM 0
Share

Nope this is fine for any amount of objects. You just need to use those functions inside your "Area trigger object's script" and every other object should have trigger, that's it. Here is the example how to use them:

Click here to see how to use those functions.

P.S. There are examples for both cases, choose approach that you like more.

avatar image
0

Answer by kingcoyote · Apr 02, 2015 at 05:26 PM

There are a few static functions in the Physics class that might solve this problem, depending on the shape of the area you are searching, the size of the area, and the size of the objects you are looking for.

OverlapSphere will return an array of all colliders that are in, or touching, the sphere. This one would work best if a sphere is suitable for the sizing.

CheckSphere is similar, but returns a bool indicating the presence of a collider and may not check inside the sphere.

RayCast casts a ray and returns information on what it hits. But you would need an array of rays cast, and this could be computationally expensive, depending how large of an area you are looking at and how small the objects you are looking for will be.

SphereCast casts a sphere along a ray, which is essentially a capsule version of SphereCheck.

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

21 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 avatar image

Related Questions

Disable Camera Movement,Stop camera movement 0 Answers

Emit Particle upon Death 2 Answers

Camera switching : C# onTriggerEnter not working 1 Answer

How do I move the camera to another object in the scene on mouse down? 1 Answer

How can I set up cameras to track the player from room to room? 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