Hi, I have a prefab with AnimateLenny script attached:
function move(hit : MyEnemy){
[...]
}
During runtime I have a BattleController class with Update that calls a function in MyPlayer Object with “StartCoroutine”. In that function I don’t have any yield, but I call the “move” function in AnimateLenny with Lenny.GetComponent(AnimateLenny).move(hit).
“hit” is MyEnemy type.
When he do the last call… well… Unity crashes.
I debugged the code but it crashes when it get to the line “function move(hit : MyEnemy){”.
I edited the script just for my this test and Unity keeps crashing.
I explain:
I have a “Cubez” prefab (in “Resources” folder) with “SomeScript” script attached. SomeScript:
#pragma strict
function move(){
yield WaitForSeconds(1.0);
}
In my scene I have an empty GameObject with “GoScript” script attached. GoScript:
#pragma strict
var test : CallSome;
function Start () {
test = new CallSome();
test.instance = Instantiate(Resources.Load("Cubez", Transform),Vector3(0,0,0), Quaternion.identity) as Transform;
}
function Update () {
if(test.go()){
StartCoroutine(test.getAndMove());
}
}
Plus I have “CallSome” script with “CallSome” class (used by “GoScript” script). CallSome:
#pragma strict
class CallSome{
var instance : Transform;
var i : int;
function CallSome(){
i = 0;
}
function getAndMove(){
var script : SomeScript = instance.GetComponent(SomeScript);
yield script.move();
}
function go() : boolean{
if(i < 6) i++;
return i == 5;
}
}
My GoScript calls “StartCoroutine(test.getAndMove());” that calls “yield script.move();” and Unity crashes (before doing ANYTHING in move() function, neither an eventual Debug.Log(“some”) in the first line).
Why? Please help me