Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 manuel2258 · May 14, 2016 at 05:23 PM · c#triggerphysics2dcollider2dnot working

OnTriggerExit2D Does not work

Hey guys, At first i want to appologys for my bad english, so my probleme is that the OnTriggerExit2D Function dont get called. using UnityEngine; using System.Collections; public class outofcam : MonoBehaviour { void OnTriggerExit2D(Collider2D colli) { if(colli.gameObject.tag == "outofcam") { Destroy(colli.transform.parent.gameObject); } if (colli.gameObject.tag == "cloud") { int newy = Random.Range(0, 6); colli.transform.position = new Vector2(transform.position.x + 50, newy); } } } In my game there are some flying clouds which should go back if they go out of the bound which is a gameobject with the code above. So in my Level this works perfectly, but in the Mainmenu where I wanted to have the same effect this just wont work. I also did a prefab of the bound and the clouds which also didn't work. alt text alt text I'm really confused right now and don't know what i did wrong so please help me! Thanks!

screen2.png (9.7 kB)
screen1.png (304.4 kB)
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 vintar · May 14, 2016 at 06:08 PM 0
Share

Please format your code correctly. It's illegible at the moment.

avatar image manuel2258 vintar · May 14, 2016 at 06:20 PM 0
Share

Ohh, didn't saw it don't know why this got that format. I hope its better now sry thats my first post here.

1 Reply

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

Answer by Vcontrol · May 14, 2016 at 08:38 PM

You checked that you have Rigidbody2D component attached to you Cloud gameobject?

OnTriggerEnter2D/OnTriggerStay2D/OnTriggerExit2D won't get called, if there is no Rigidbody2D component.

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 manuel2258 · May 14, 2016 at 08:42 PM 0
Share

Okey well worked for me thank you, but why did it worked in my first level, the clouds also have no Rigidbody2D ?

avatar image MelvMay ♦♦ · May 16, 2016 at 07:29 AM 0
Share

A Rigidbody2D component isn't required to get a trigger/collision callback.

When you don't add a Rigidbody2D component, the collider is static and two static colliders won't contact each other.

Collider Overview

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

How can I make it so that the Level Reloads whenever the Player touches certain Colliders or Triggers? 1 Answer

Physics2D.OverlapCircle dont detect triggers 3 Answers

Edge Collider issue 1 Answer

Collision with instantiated non-moving objects. 1 Answer

why Raycast2D doesn't work properly? 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