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 MachCUBED · Dec 22, 2011 at 10:27 PM · collisiontrigger

Sphere Collider Trigger not being Triggered on Object with two Colliders

Hi guys,

I have a prefab with a toilet bowl mesh as its only child (don't ask why!), which has the following two colliders:

  1. A mesh collider, used for physics simulation. Its purpose is to keep the player from walking through the toilet bowl. It's not set as a trigger, and it's not convex.

  2. A sphere collider, with isTrigger checked. The idea is to use it to make the lid of the toilet open automatically whenever the player gets close to it.

The toilet bowl has the following script attached to it:

 var lid : Transform;
 var ring : Transform;
 var toiletController : Transform;
 
 function Update () 
 {
 }
 
 function OnTriggerEnter(other : Collider)
 {
     if (other.GetComponent (CharacterController))
 {
     Debug.Log("Player next to toilet, add code to open the lid");
 }
 }

The lid isn't opening yet because I haven't added the relevant code yet. However, the debug message isn't showing up if the player goes into the sphere collider. This strikes me as being really strange, since the sphere collider has a radius of 3 and is properly-aligned with the toilet bowl. Moreover, the player's character controller only has a height of 0.4 and a radius of 0.18. What am I doing wrong?

MachCUBED

Comment
Add comment · Show 10
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 Lo0NuhtiK · Dec 22, 2011 at 10:53 PM 0
Share

put the trigger code on your player ins$$anonymous$$d of the toilet and see what happens. unless your player isTrigger also?

avatar image MachCUBED · Dec 22, 2011 at 11:27 PM 0
Share

$$anonymous$$y Player prefab contains a mesh for my player character as its only child, and has Animation, Character Controller, Audio Source, Player $$anonymous$$ovement.js, and PlayerAttack.js components. None of its components has an isTrigger checkbox.

avatar image Lo0NuhtiK · Dec 23, 2011 at 03:57 AM 0
Share

Did you change the code up there from what it was ealier? I don't remember it looking like that.
Edit: ...anyway... try OnCollisionEnter ins$$anonymous$$d of trigger now.
Note: make sure after you get it working, that you also have it to lower the lid after your guy is done. Women won't appreciate it if you leave it up.

avatar image MachCUBED · Dec 23, 2011 at 04:54 AM 0
Share

I removed OnTriggerEnter() and replaced it with this:

function OnCollisionEnter() {

     Debug.Log("Player next to toilet, add code to open the lid");

}

It still didn't work, so I changed it back to OnTriggerEnter(), but without the test to see if it's just the player:

function OnTriggerEnter(other : Collider) {

     Debug.Log("Player next to toilet, add code to open the lid");
 }

It still doesn't work. I also tried adding debug rays for OnCollisionEnter(), and they didn't show up at all. As for closing the lid, don't worry, the toilet is supposed to be one of those fancy Japanese-style ones, so I won't forget to make it close for the ladies! ;)

avatar image MachCUBED · Dec 23, 2011 at 06:09 AM 1
Share

I got it to work using OnTriggerEnter(), it turns out that my script was attached to the prefab ins$$anonymous$$d of the mesh. The mesh is the object that has the relevant colliders, not the prefab, so attaching the script to the prefab ins$$anonymous$$d of the enclosed mesh was a stupid mistake on my part.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

OnTriggerEnter - Same collider triggers multiple times?, is size a factor? 4 Answers

Terrain doesn't collide with my mesh 1 Answer

Question about collision and trigger 2 Answers

Scoring Issue 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