Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Der_Kevin · Dec 16, 2015 at 03:36 PM · pathcheckyield waitforseconds

check path and waitforseconds. countdown keeps counting down

Heyhey!, so iam working on this game: https://dribbble.com/shots/2119802-iMaze

pretty easy thing, you get a generated maze and have to solve it in a certain time. for this i am using a navmesh on the ground. navmesh obstacles on the maze tile borders and a navmesh agent on the red ball. and every time you rotate a mesh, the "StartCoroutine(CheckPath());" gets called.

the navcheck script looks like this at the moment:

 using UnityEngine;
 using System.Collections;
 using plyBloxKit;
 using qtools.qmaze;
 using qtools.qmaze.example;
 
 public class NavMeshCheck : MonoBehaviour 
 {
     public Transform  target;
     public GameObject Ampel_Green;
     public GameObject Ampel_Red;
     public GameObject Attention;
     public bool       Path;
 
     private NavMeshAgent agent;
     private GameObject   rotatingPiece = null;
 
     void Awake() 
     {
 
         Ampel_Red.SetActive(true);
         Ampel_Green.SetActive(false);
 
         Attention.SetActive(false);
 
         //for (int i = 0; i < pieceList.Count; i++) 
         //{
             //QMazePieceRotator piece = pieceList[ i ];
             //piece.onPieceRotated += OnPieceRotated;
         //}
 
     }
 
     public void OnNewMazePieceGenerated( QMazePieceData piece )
     {
         Debug.Log( "New piece generated: " + piece.geometry.name );
         var rotator = piece.geometry.GetComponent<QMazePieceRotator>();
 
         // Register as lister of the pieces that can rotate
         if( rotator != null )
         {
             rotator.onPieceRotationBegin += OnPieceRotationBegin;
             rotator.onPieceRotationEnd   += OnPieceRotationEnd;
         }
     }
 
     void OnPieceRotationBegin( GameObject piece )
     {
         rotatingPiece = piece;
     }
 
     void OnPieceRotationEnd( GameObject piece )
     {
         //CheckPath();
         StartCoroutine(CheckPath());
 
         return;
 
         if( rotatingPiece == piece )
         {
             rotatingPiece = null;
             //CheckPath();
             StartCoroutine(CheckPath());
         }
 
 
     }
 
 
 
     //void CheckPath() 
     IEnumerator CheckPath()
     {
         agent = GetComponent<NavMeshAgent>();
         NavMeshPath path = new NavMeshPath();
         agent.CalculatePath(target.position, path);
         //GetComponent<Animation>().Play("Ball_Jump");
 
 
         if (path.status == NavMeshPathStatus.PathComplete) 
         {
 
             yield return new WaitForSeconds(3f);
             Path =true;
             Ampel_Green.SetActive(true);
             Ampel_Red.SetActive(false);
 
             Attention.SetActive(true);
             plyBloxGlobal.Instance.SetVarValue("Puzzle", false);
 
 
             Debug.Log("PathComplete");
         }
         else 
         {
                 Path =false;
                 //Ampel_Red.SetActive(true);
                 //Ampel_Green.SetActive(false);
                 
                 //plyBloxGlobal.Instance.SetVarValue("Puzzle", true);
                 Attention.SetActive(false);
                 
                 Debug.Log("PathInvalid");
         }
     }
 }
 

and everything works fine so far, but i have this "yield return new WaitForSeconds(3f);" cause i want to give the player a short delay before the maze gets marked as solved (Path =true;).

but the problem i am facing now is, when this happens: the maze gets solved (Path =true;) and during the three seconds countdown you change your mind and rotate another peace which leads to the situation that the maze is not solved. so the path from ball to exit is not true. But for some reason the countdown is still counting down in this case and sets the path to true. But it should be resetted

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

29 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

Related Questions

Checking if a 2D joint gets pulled or pushed 0 Answers

Move a object around another object 0 Answers

Need help with an image path script 0 Answers

Issue with waypoint tiles 0 Answers

Waiting for time for enemy to attack 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