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 mealone · Sep 18, 2014 at 04:52 PM · 2dcollisionscenerigidbody2d

collision2D not working - help?

Hey guys. I have a weird problem which i can't figure out. I have set up a scene where collision occurs in a 2d scene between two gameobjects. When the collision occurs the integer variable "bigger" on one of the gameobjects changes from 0 to 1. This works perfectly when I run for the first time, but whenever i switch scenes and come back to this scene it stops working.... and I have no idea why. There are 2d rigidbodies attached, and the collision occurs initially, nothing changes in the script outside of loading another level/scene, and then returning back to the scene, and then the collision stops working. I have adjusted the colliders, double checked the rigidbodies, I honestly do not know what is going on. Can someone help?

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 kurotatsu · Sep 18, 2014 at 09:57 PM 0
Share

It'd help to see some code.

avatar image Madcowe · Sep 18, 2014 at 10:08 PM 0
Share

If you could provide more details, or better yet, some code that would help us help you a lot better :D

2 Replies

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

Answer by mealone · Sep 19, 2014 at 01:21 AM

so i figured it out after a few hours of debugging. The game objects were set to the default layer and there was a gameObject in the next scene which was scripted to ignore collisions on the default layer, I didn't know that this script would've remained consistent across scenes, and this caused the collision to stop working. Everything worked when I changed the layer for the gameobjects from default to a new layer.

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
avatar image
1

Answer by Pyrian · Sep 18, 2014 at 08:23 PM

I don't suppose one of the objects is destroyed or somehow deactivated in the collision, and one of the objects is persistent?

Deactivating a collider in any way (e.g. destroying the object) during collision event code prevents further events from getting called for the same collision. The order of the events is based on the object id's, which in most cases is the order they were created in the editor (bleccch) - not something you want to rely on, and can potentially change just by reloading the scene (particularly if one of the objects isn't destroyed during scene changes).

If this describes your problem, the solution is to not deactivate the collider during the event, but instead set a flag and deactivate it in Update.

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

26 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 avatar image avatar image avatar image avatar image 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 of child is detected as collision of parent with Rigidbody2D 0 Answers

Object hits another but doesnt bounce off again. 0 Answers

How can I prevend two Circle Collider's (2D) overlapping on collision? 1 Answer

Two dynamic rigidbodies that dont conserve momentum 0 Answers

Unwanted results from 2D collisions? 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