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 skate4life13010 · Nov 05, 2014 at 11:50 AM · movementcrashgame

Game keeps locking up "deleted gameObject" in hierarchy

So this script just checks after every movement if Im still on a cube on the grid. Now only SOMETIMES when the level is reset my game keeps resetting I assume because my boolean doesn't change. It doesn't do this because I'm moving too fast or ANY reason i can figure out I've been trying to troubleshoot doing the same thing over and over but only sometimes it happens at random occasions. It also sometimes locks up when I move to a different scene. In the hierarchy all my game objects are deleted and says "deleted gameObject" Any Ideas?

var floorCol : boolean = false;

function OnCollisionEnter(coll: Collision){

      if(coll.gameObject.tag=="floor"){
          floorCol=true;
          }

}

function OnCollisionExit(coll: Collision){

      if(coll.gameObject.tag=="floor"){
          floorCol=false;            
      }

}

function Update(){

  if(floorCol == false){
      Debug.Log("reset");
      floorCol=true;
      Application.LoadLevel(Application.loadedLevel);
  }
  else if(floorCol==true){
      Debug.Log("no reset");
  }

}

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Uldeim · Nov 07, 2014 at 03:55 AM

I don't really think there's enough information there (though I could be wrong), but it seems possible to me that the collision isn't firing before the first Update() call on whatever has this script attached.

Now, I don't really know much about Unity's internal bits and whether the physics engine and Update calls might have timing issues like that, but try something like:

 if (floorCol == false)
 {  
    Debug.Log("Floating...");
    floatingCubeCount++;
    if (floatingCubeCount > 15)
    {
       Debug.Log("reset");
       floorCol = true;
       Application.LoadLevel(Application.loadedLevel);
    }
 }
 else  //no real need for the 'else if' here
 {
    Debug.Log("We're all fine here now...  how are you?");
 }


Then, if you occasionally see a few "Floating..."s before whatever, that's probably the issue, and hopefully the delay should fix it anyways.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Where is a good place to start Developing my Game? 5 Answers

Player Rotation 1 Answer

Teleport enemy after player collides with an object? 0 Answers

Help with array collision script ! 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