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 gamesmarlac · Nov 06, 2018 at 05:44 AM · gameobjectcrashcollision detectionscene-loadingfreeze

I need your help I have a script to reload a scene if the player go on a unauthorized gameObject but the game freeze please help.

I need your help because I don't know why that is happening.

Blockquote

using System.Collections;

Blockquote

using UnityEngine;

Blockquote

using UnityEngine.SceneManagement;

 namespace UnityStandardAssets.Characters.FirstPerson
 {
     public class WorldLimitePlaye : MonoBehaviour
     {
 
 
         public Canvas LimiteUI;
         public float TimeBeforeReload;
         public float TimeBeforeReloadInWater;
 
         private float TimeRemaning;
         private CharacterController player;
         private bool textActive = false;
         private bool isSafe = true;
         private Collider otherr;
         public UnityStandardAssets.Characters.FirstPerson.FirstPersonController firstPerson;
         private bool isJumping = false;
         private bool previoslySafe = true;
         private Swim swim;
         private bool inwater;
         private string colider;
         // Use this for initialization
         void Start()
         {
 
 
             swim = GetComponent<Swim>();
             inwater = swim.watherLimite;
             player = GetComponent<CharacterController>();
             TimeRemaning = TimeBeforeReload;
 
             LimiteUI.gameObject.SetActive(false);
         }
 
         // Update is called once per frame
         void Update()
         {
             inwater = swim.watherLimite;
             isJumping = firstPerson.m_Jumping;
 
 
 
                 if (TimeRemaning <= 0)
                 {
                 PlayerPrefs.SetString("Load", "true");
                 SceneManager.LoadScene(SceneManager.GetActiveScene().name);
                 }
 
 
 
         }
         public void OnTriggerExit(Collider other)
         {
             isJumping = firstPerson.m_Jumping;
             if (other.tag == "WorldLimite")
             {
                 isJumping = firstPerson.m_Jumping;
                 if (isJumping == false)
                 {
                     StopAllCoroutines();
                     LimiteUI.gameObject.SetActive(false);
                     isSafe = true;
                     previoslySafe = true;
                 }
                 else
                 {
                     StartCoroutine(jump());
                 }
 
 
             }
             if (other.tag == "Water Limite")
             {
                 StopAllCoroutines();
                 LimiteUI.gameObject.SetActive(false);
                 isSafe = true;
                 previoslySafe = true;
             }
             //if (other.tag == "WorldLimite" && other.tag  == "Water Limite")
            // {
                      
          //  }
           //  else
           //  {
             
               //  previoslySafe = true;
              //   isSafe = true;
                
              //   StopAllCoroutines();
              //   LimiteUI.gameObject.SetActive(false);
            // }
 
         }
 
          IEnumerator jump()
         {
             yield return new WaitForSeconds(0.0f);
             while (3 != 1)
             {
                 if (colider == "WorldLimite")
                 {
 
                 }
                 else
                 {
                     isJumping = firstPerson.m_Jumping;
                     if (isJumping == false)
                     {
 
                         LimiteUI.gameObject.SetActive(false);
                         isSafe = true;
                         previoslySafe = true;
                         StopAllCoroutines();
                     }
                 }
             }
         }
         IEnumerator Exit()
         {
             isJumping = firstPerson.m_Jumping;
             if (isJumping == true)
             {
                 isJumping = firstPerson.m_Jumping;
                 yield return new WaitForSeconds(1f);
                 isJumping = firstPerson.m_Jumping;
                 inwater = swim.watherLimite;
 
                // if (isJumping == false)
                // {
                     isSafe = true;
 
                     previoslySafe = true;
                 LimiteUI.gameObject.SetActive(false);
                 StopAllCoroutines();
                 // }
             }
            
 
             //   if (isJumping == false)
             //   {
             ///   isSafe = true;
             //  previoslySafe = true;
             //Limite.gameObject.SetActive(false);
             //}
 
         }
          
 
         IEnumerator ExitWater()
         {
             isJumping = firstPerson.m_Jumping;
             yield return new WaitForSeconds(0.1f);
             isJumping = firstPerson.m_Jumping;
             inwater = swim.watherLimite;
             if (isSafe == false)
             {
 
 
              
                 isSafe = true;
                     previoslySafe = true;
                 LimiteUI.gameObject.SetActive(false);
                 StopAllCoroutines();
 
             }
             //   if (isJumping == false)
             //   {
             ///   isSafe = true;
             //  previoslySafe = true;
             //Limite.gameObject.SetActive(false);
             //}
 
         }
         public void OnTriggerStay(Collider other)
         {
            
             if(isJumping == false)
             {
                colider = other.tag;
             }
             otherr = other;
             if (other.tag == "WorldLimite")
             {
 
 
                     previoslySafe = false;
                     otherr = other;
                     isSafe = false;
 
                 TimeRemaning = TimeBeforeReload;
                 LimiteUI.gameObject.SetActive(true);
                     StartCoroutine(ComptRebourd());
                     StartCoroutine(ComptRebourdTemps());
                 print("12345678");
 
             }
             if (other.tag == "Water Limite")
             {
 
 
 
                     previoslySafe = false;
                     otherr = other;
                     isSafe = false;
                 TimeRemaning = TimeBeforeReloadInWater;
                 LimiteUI.gameObject.SetActive(true);
                     StartCoroutine(ComptRebourdWater());
                     StartCoroutine(ComptRebourdTemps());
 
 
             }
         }
 
         public void OnTriggerEnter(Collider other)
         {
             otherr = other;
             if (other.tag == "WorldLimite")
             {
                 if (previoslySafe)
                 {
                     previoslySafe = false;
                     otherr = other;
                     isSafe = false;
 
                     TimeRemaning = TimeBeforeReload;
                     LimiteUI.gameObject.SetActive(true);
                     StartCoroutine(ComptRebourd());
                     StartCoroutine(ComptRebourdTemps());
                 }
 
             }
             if (other.tag == "Water Limite")
             {
 
 
                 if (previoslySafe)
                 {
                     previoslySafe = false;
                     otherr = other;
                     isSafe = false;
                     TimeRemaning = TimeBeforeReloadInWater;
                     LimiteUI.gameObject.SetActive(true);
                     StartCoroutine(ComptRebourdWater());
                     StartCoroutine(ComptRebourdTemps());
                 }
 
             }
 
         }
 
         IEnumerator ComptRebourd()
         {
             yield return new WaitForSeconds(TimeBeforeReload);
             if (isSafe == false)
             {
                 PlayerPrefs.SetString("Load", "true");
                 SceneManager.LoadScene(SceneManager.GetActiveScene().name);
             }
 
         }
 
 
 
         IEnumerator ComptRebourdWater()
         {
             yield return new WaitForSeconds(TimeBeforeReloadInWater);
             if (isSafe == false)
             {
                 PlayerPrefs.SetString("Load", "true");
                 SceneManager.LoadScene(SceneManager.GetActiveScene().name);
             }
 
         }
 
 
         IEnumerator ComptRebourdTemps()
         {
 
             while (TimeRemaning >= 0f)
             {
                 yield return new WaitForSeconds(1f);
                 if (isSafe == false)
                 {
                     TimeRemaning = TimeRemaning - 1f;
                     print(TimeRemaning);
                 }
 
             }
 
         }
     }
 }




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

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

143 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 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 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 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 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 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

My code freezes Unity... 1 Answer

Editor freezed, When create 3D Game Object. 1 Answer

Android Loading scene / loading assets problem 1 Answer

Unity freezes on play 1 Answer

Unity Webplayer doesn't work on Mac? 3 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