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
3
Question by shugoryuu · Mar 04, 2012 at 07:37 PM · collisioncolliderontriggerenterontriggerstay

OnTrigger* triggered only once

Hello !

I really would have preferred not to bug anyone about this problem of mine, but I really am desperate about it now. Alright, so thank you in advance for all the help you guys will provide me.

Before explaining the problem, I simply want to let you guys no I have little to none experience in Unity and Game Development altho I am a web developer. A friend of mine and I wanted to try it out using the incredible 2d Toolkit asset which is working just fine as of now.

The context of my Proof of Concept is as follow : I have a scene with 3 Sprites on it. Each one of it has a Mesh Collider and the Player has a Rigid Body. The player can move around (in a 2D manner) and my next step would have been to make impossible for the player to walk over the other sprites.

I've clicked on the 'is Trigger' option of the Box Collider panel and coded (in C#) the onTrigger events as follow :

 void OnTriggerEnter(Collider trig)
 {
     Debug.Log("Enter");
 }        
 
 void OnTriggerStay(Collider trig)
 {
     Debug.Log ("Stay");
 }

 void OnTriggerExit(Collider trig)
 {
     Debug.Log("Leave");
 }    

Everything works fine if my character enters and leaves one of the Sprite. However, if he tries to enter it again, or enter another one, none of the trigger are called again.

Trying to find a solution over the Net, but nothing could explain explicitly what my problem might be.

Thank you

Comment
Add comment · Show 2
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 Andrea_Marchetti · Jul 19, 2017 at 07:06 PM 0
Share

aldonaletto found out it was caused by the collapse button. However I wonder why it works, because you said you are trying to make a 2D game and your code is for 3D games. Everything should be with 2D at the end: like OnTriggerEnter2D (Collider2D collider) etc... So it works? I always had problems when I was using the 3d functions...

avatar image aldonaletto Andrea_Marchetti · Jul 20, 2017 at 04:29 AM 0
Share

This question was posted before the 2D mode was available in Unity - 3D physics with the Z axis frozen was the only solution for 2D games. The 2D physics engine appeared more than one year later, in Unity 4.3, and is by far the preferable choice for 2D games (much faster and lighter). The 3D and 2D engines don't talk to each other, thus only the "2D ending" functions and components must be used together in a 2D game. You can even use both engines in the same scene, but they won't interact with each other: a 3D Rigidbody won't hit a Rigidbody2D, a Collider2D won't stop a 3D regular Rigidbody, etc.

1 Reply

· Add your reply
  • Sort: 
avatar image
7

Answer by aldonaletto · Mar 04, 2012 at 07:57 PM

The code seems ok. Verify that damned Collapse button in the Console view: when it's pressed, the console doesn't print repeated messages, what usually drives programmers nuts!

Comment
Add comment · Show 4 · 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 shugoryuu · Mar 04, 2012 at 10:30 PM 0
Share

Woah, that was as simple as that. I guess Unity should display at least the number of stack it got from the same message. I truly wasn't aware of this. Thank you so much, it helped me to move on :)

avatar image aldonaletto · Mar 05, 2012 at 12:11 AM 1
Share

This button is a Devil's creation! It has fooled lots of users (me included), from noobs to experts. Number the messages is a good suggestion!

avatar image Jourdanis · Jul 19, 2017 at 06:41 PM 1
Share

Damn, I was searching for this answer for about 20 $$anonymous$$utes now, never would have guessed it was this simple. Thank you.

avatar image SamyTaz · Jul 29, 2017 at 02:37 PM 0
Share

How to Stop All Game Sound in All Scenes by simply pressing On/Off Button Hello I'm New in this field So please help me .. I just want to stop all music by pressing a simple button "Off" from main menu and Want to Start Again All Sound of the game By Pressing another button "On" also located on main menu ...

i designed 20 Levels,Scenes for my game and want to stop All sound of the game from main menu But i can only stop the Sound,$$anonymous$$usic that is on the main menu when i go to the next scenes,Level Sound is not $$anonymous$$ute .

I know its possible by using Void Awake() Function But i'm New So Please Give me the right solution,Logic ...Thanks

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

OnTrigger event when colliders are already touching eachother 1 Answer

Collision not detected 3 Answers

Can someone clarifies OnTriggerEnter, OnTriggerExit and OnTriggerStay for me? (I have image included already) 0 Answers

Collision Detection without a RigidBody 2 Answers

OnTriggerEnter with exact spot of collision 2 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