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 kinggamer1235 · Aug 31, 2014 at 03:48 PM · playerdestroy

How to make triggers collide with player?

I have all my code in the player object, when the player collides with the door and has 2 keys then the door will disappear and a new sprite will take its place that looks like the same door but its open instead.

Well... thats what should happen. I have checked the box in the closed door object the says Is Trigger and started to test it but when i walk to the door without any keys or just one i go straight through the door without it even changing to and open door, but when i have 2 keys and walk to the door it changes correctly.

So my question is how do i make objects that have Is Trigger checked still collide with other objects?

Thanks in advance!

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 aldonaletto · Aug 31, 2014 at 04:31 PM

Your question isn't clear enough. What's exactly the problem? Do you want to know how to make the door "solid" until the player has got two keys? A possible solution is to use two objects, a trigger and a collider: detect when the player enters the trigger, check whether it has the two keys, and if so delete the collider object and replace the sprite. NOTE: the trigger must be bigger than the collider (say, 0.2 to 0.3 meters on each side) in order to react to CharacterControllers.

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 kinggamer1235 · Aug 31, 2014 at 05:30 PM 0
Share

yeah thats what i want to do but how would i turn off the collider when i walk to the door with the keys

avatar image aldonaletto · Aug 31, 2014 at 06:10 PM 0
Share

Don't set IsTrigger in the door's collider: child a cube to the door, adjust its dimensions to cover the area you want, uncheck the Renderer component to make it invisible and check the cube collider's Is Trigger checkbox. In some player's script, add a code like this:

 function OnTriggerEnter(other: Collider){
   if (other.CompareTag("Door") && playerHas$$anonymous$$ey1 && playerHas$$anonymous$$ey2){
     Destroy(other.transform.parent.gameObject);
   }
 }

Obviously, the cube must be tagged as "Door", and you must have two boolean variables playerHas$$anonymous$$ey1 and playerHas$$anonymous$$ey2 that are set when the player get the keys (or whatever variables you're currently using to know whether the player has got the keys).

avatar image
0

Answer by BMayne · Aug 31, 2014 at 04:57 PM

Hey There,

A trigger is a collider that does not have collision (as in blocks movement). If you want a trigger zone you do what aldonaletto was saying. Have one box collider as your door and a second one as the trigger.

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 kinggamer1235 · Aug 31, 2014 at 05:11 PM 0
Share

Hi B$$anonymous$$ayne, how do i do that?

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Distance destroy object 3 Answers

Destroy player on spawn if he already exists in scene 1 Answer

collision wont work 1 Answer

i want to destroy a projectile after it passes a limit on x axis after instantiation(2d game) 1 Answer

Rigidbody 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