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 Kwayzie · Sep 05, 2013 at 05:04 AM · collidertriggerresetbox colliderhorror

box collider trigger question

ok so i kinda have 2 questions. ive been able to figure out how triggers work with box colliders and send messages and look at all that fun stuff. but now the hard parts. 1st question im wondering if its possible to have a collider trigger after walking across it like 2 times? for example i want to be able to walk across it once with nothing happening, then when u walk over it again thats when it triggers whatever. next question is is it possible to make them appear and dissapear at certain times. another example being like i have a level that requires you to collect keys. when i pick up the first key i want to be able to delete all those box colliders i had before and then make a whole new set of them. then again for the second key and so on. i hope i made sense in all that, if not ill try to explain it more.

sorry if its kinda long :(

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

1 Reply

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

Answer by GC1983 · Sep 05, 2013 at 06:44 AM

Question 1: Create an int count so it will up the count each time you walk over the collider. If the desired count is met, trigger the effect.

Question 2: Im not sure what you mean by deleting all the box colliders from before. But, instead of deleting the colliders, just turn the activate/deactivate through object.renderer.enabled = true/false.

 void OnTriggerEnter(Collider other)
 {
      if(other.gameObject.tag == "Tag Name")
      {
           other.renderer.enabled = true;
      }
 }
Comment
Add comment · Show 11 · 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 Kwayzie · Sep 05, 2013 at 08:57 PM 0
Share

can u give a example of how in count works? im still a noob with scripting. for the second question that might work. but just to explain what i mean is like i have a house and you have to get keys to escape with a ghost trying to kill you. now as u get more keys i want the ghost to be more hostile and appear more often. now my first thought would be to add more colliders after every key but get rid of the ones from the key before so u dont trigger those ones. or so you wont trigger all of them before u get all the keys. does that make more sense?

avatar image GC1983 · Sep 05, 2013 at 10:29 PM 0
Share
 int count = 0;
 
 void OnTriggerEnter(Collider other)
 {
      count++;
      
      if(count >= 3)
      {
            //do something
      }
 }

As for the keys, just place them around the scene and give them a collider and set them to isTrigger so they wont be in the way and will trigger if you collide. In the OnTriggerEnter method for the keys, have them update the ghost aggression and mark you have possession of the key so you can unlock whatever door it belongs to, then just simply delete or hide the key you collided with. You can call whatever in the OnTriggerEnter or have a method called within it. $$anonymous$$ake sense?

avatar image GC1983 · Sep 05, 2013 at 10:30 PM 0
Share

What would addin more colliders do?

avatar image coward · Sep 05, 2013 at 11:24 PM 0
Share

I think you're getting your terms mixed up $$anonymous$$wayzie. Colliders are simply the components that trigger collision messages. The key itself isn't the collider.

As in GC's answer, the count is the way to track the number of times a collisions has occurred, but the collider will fire every time, until you turn it off. But it's the count that then controls when your object's behaviour changes.

As for the second part - if you have a key prefab with a collider attached, you can easily create and destroy your keys in the scene. The destroy can happen when the collider triggers, and you can remove the key from the scene (look at gameObject.Destroy in the docs) and as for adding more keys, if you are using a prefab you can use Instantiate to create a game object in a particular position in your scene (look at GameObject.Instantiate in the docs).

avatar image Kwayzie · Sep 06, 2013 at 01:13 AM 0
Share

thanks GC thats what i was looking for int count wise :) but i still dont think yall understand me about the other one lol i really suck at explain things sorry :( how about this...hmmm i have my lock system in place and all my keys set up for different doors, destroying the keys when picked up so all that works just fine. but lets say when i first begin the game i want there to be no box colliders around the house, then once i grab lets say "key1" i want lets say "group 1" of the box colliders to be active which are spread through out the house so you can trigger them when walked across. then once you grab "key 2" i want "group 1" of colliders to go away so you cant trigger them any more and then make "group 2" active or show up....i really hope that explanation is better this time.

Show more comments

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

18 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

Related Questions

Jumpscare (Triggers and stuff) 1 Answer

Problems with the Trigger Collider (randomly fictional) 1 Answer

Can't click gameobject when over another trigger? 1 Answer

How to use different and distinguish between different box colliders? 1 Answer

play a door animation with collider 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