In my scene I have 2 Charas (Wasch and Lucat) walking next to each other.
By hitting space, the player can switch between the two, which ever he wants to “posses”.
One script controlls the switching.
Another script takes care of the camera-movement (handled with waypoints)
The Controller-Script:
private var waschActive : boolean = false;
private var camCall = GameObject.Find("Main Camera").GetComponent("CamMove");
function Update ()
{
if (Input.GetButtonDown("Jump")) // on Spacebar down, do:
{
// switch between Charas
waschActive = !waschActive;
// tell the MainCam, which PC to possess
if ( waschActive )
{
Debug.Log("waschActive");
//camCall.LucatToWasch();
}
}
}
Here's the function that gets activated by the camCall.
function LucatToWasch ()
{
Debug.Log("LucatToWasch started");
while ( !lastPointReached )
{
//as long as first waypoint hasn't been reached yet,
//lerp Camera towards it and make it face in the same direction
while ( !firstPointReached)
{
Debug.Log("First Point not reached yet");
Debug.Log(transform.position);
transform.position = Vector3.Lerp
(camPositionLucat.position, camPathPointLucat.position, 5);
Debug.Log(transform.position);
if (cameraTrans.position == camPathPointLucat.position)
{
Debug.Log("first Waypoint reached");
firstPointReached = true;
}
}
}
}
Currently the camCall is commented out and if I hit space I get the "WaschActive"-Message.
(Other functionalities I implemented and left out for clarity work perfect as well)
Now the strange thing is: if I un-comment it, Unity freezes before it even prints the "WaschActive"-Message! O.o No Debug.Log-calls at all (non of the camMove-script either). No errors. The statistics-window freezes as well...
So what's happening?
Does Unity freez before it even reaches the problematic code??
Will Debug.Log not get called if it freezes.
Thanks a lot in advance!
Greetz, Ky.
~~~~~~~~~~~~~
Edit:
As burnumd said and GargerathSunman on the Forums confirmed, Unity will always hang before drawing Debug.Log!! So for infinite Loops, Debug.Log won’t do…
I put in some yield; and now it doesn't crash anylonger! =D It's still weird, but sort of works... =)