|
I am currently working on a game that requires me to have a gameObject follow a set path from one waypoint to another. However While I run the program the moment my script causes Unity to lock up. Here is my current script.
I have having it look for tags and just named gameobjects. But no luck. Any idea on what I did wrong?
(comments are locked)
|
|
Let's simplify your while loop to just the things that deal with its exit case, i:
If you enter the while loop while num1 >= num2 (i.e. while the character is farther than change from ANY WAYPOINT) it is an infinite loop. Infinite loops are very very bad. You might just need a "yield;" at the end of the while block.
(comments are locked)
|
|
Start by adding some
functions into your PathOne() function in many different places. Make sure you change the message to something different for each one you place. I'd put them like this:
Run that code and see if you can see the debug log. Does it get stuck in an infinite loop? Do certain lines of code never get called? Please do this and update your answer.
(comments are locked)
|

I have done that and what happens is that it reports the gameobject is lost and needs to have they way points stated. So I added
This enabled the gameobjects to know where to go when the game started. Problem is that it completely freezes unity before it can perform anything. A college and I believe it's due to the array. He and I tried various different ways around it from redoing the counter for i to completely removing it. Still froze / causes Unity to stop responding (so I have to force quit the program). Though I do like knowing about the Debug.Log. That will help more in the future.
oh yeah forgot to mention that I corrected the PathOne fuction with the GameObject.FindWithTag so they would be uniformal.