Hi everyone, this is my script, it prints everything correctly, so everything seems to be recognized and found, but when i want to play the animation of “Bird” i get a null reference exception “Object not set to an instance of an object”, even though it prints the bird as gameobject bird! i’m very confused! how can that be? Maybe it has something to do with the fact, that the script is on a empty sprite and the object “Bird” is a child of the sprite?
Has someone any idea?
Thanks:)
var Baby : GameObject;
var BabyPosz : float;
var animationToolkit;
var Bird;
function Start () {
Baby = GameObject.Find("baby");
Bird = GameObject.Find("bird");
animationToolkit = gameObject.GetComponent("tk2dAnimatedSprite");
}
function Update () {
BabyPosz = Baby.transform.position.z - 3.7;
transform.Translate(0,0,-0.03);
if(transform.position.z < BabyPosz){
print(Bird);
print(animationToolkit);
print(Baby);
print(BabyPosz);
Bird.animationToolkit.Play("Fly");