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 Azaroth · Oct 03, 2012 at 05:29 PM · collisiontriggerdetection

Trigger Collision Detection

Hey guys, im reading this book that has an example that says just to establish this function without even its use in the Update() or Start():

void OnTriggerEnter(Collider col){ if(col.gameObject.tag == "Player"){ transform.FindChild("door").SendMessage("DoorCheck"); } }

The door child of the outPost Gameobject is just a door with 3 animations (idle, open, close) and the DoorCheck is the function in the door script that activates the sounds and the animations of the door.

The script i wrote above is attached on the outPost, and the character has no other scripts on it exept the prefab scripts.

The problem is that nothing happents. What can i do?

Comment
Add comment · Show 3
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 AlucardJay · Oct 03, 2012 at 05:28 PM 1
Share

This video may help : http://www.unity3dstudent.com/2010/07/beginner-b13-trigger-collision-detection/

And the Unity Scripting Reference : http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html

Here is a video series by the same author as the book :

Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/essential-skills/

Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/beginner/

this is the YouTube link for the above as one playlist : http://www.youtube.com/watch?v=-oXYHNSmTxg&list=PL27B696FB515608D2&feature=plcp

the Unity Wiki : http://wiki.unity3d.com/index.php/Tutorials

A list of resources : http://answers.unity3d.com/questions/12321/how-can-i-start-learning-unity-fast-list-of-tutori.html

avatar image Seth-Bergman · Oct 03, 2012 at 06:17 PM 0
Share

in the future, try to remember to format your code block by selecting all the code, and hitting the "101010" button.. I'd fix it for you but I'm afraid to break your link..

as for your question, you will need to make sure your player is tagged as "Player" (note that this is looking at the TAG, not the name of the object), and it sounds like you have childed the door to outPost.. that needs to be named door.. the outPost object also needs a collider attached (and the player too, or a character controller), and the collider must be set to "is trigger". One of the objects will also need a rigidbody (probably the outpost if you are using a character controller), just set that to "is kinimatic"... still with me?

@alucardj has some good links, but missing one crucial one:

http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html

the collision action matrix at the bottom of the page will help explain what combinations of objects can and cannot send trigger signals.. I've only noticed one slight discrepancy myself, as I've described here:

http://answers.unity3d.com/questions/292387/kinematic-trigger-with-static-collider-no-trigger.html

otherwise the collision matrix is very useful to understand why triggers often don't work!

avatar image AlucardJay · Oct 03, 2012 at 06:26 PM 0
Share

Thanks for the tip, great advice. I never thought of including the collision matrix in this type of question. I was plowing through the moderation que so this got a generic comment based on the Unity3Dstudent series. But yours should be an answer, or as Fattie would say, zoop it to an answer =]

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Seth-Bergman · Oct 03, 2012 at 06:49 PM

in the future, try to remember to format your code block by selecting all the code, and hitting the "101010" button.. I'd fix it for you but I'm afraid to break your link..

as for your question, you will need to make sure your player is tagged as "Player" (note that this is looking at the TAG, not the name of the object), and it sounds like you have childed the door to outPost.. that needs to be named door.. the outPost object also needs a collider attached (and the player too, or a character controller), and the collider must be set to "is trigger". One of the objects will also need a rigidbody (probably the outpost if you are using a character controller), just set that to "is kinimatic"... still with me?

@alucardj has some good links (in the comment above), but missing one crucial one:

http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html

the collision action matrix at the bottom of the page will help explain what combinations of objects can and cannot send trigger signals.. I've only noticed one slight discrepancy myself, as I've described here:

http://answers.unity3d.com/questions/292387/kinematic-trigger-with-static-collider-no-trigger.html

otherwise the collision matrix is very useful to understand why triggers often don't work!

(...........ZOOP!)

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

11 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

Related Questions

Collision problem when spawning in the collider 1 Answer

Detecting Trigger Collision for Mecanim Animator 0 Answers

Best practice for OnTriggerEnter detection 1 Answer

How to implement ECS trigger collisions? (Unity.Physics 0.50) 1 Answer

I need help with collision detection event 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