2D Toolkit Forum
2D Toolkit => Support => Topic started by: Kenzo on July 23, 2013, 07:55:26 pm
-
Hi all,
I've created a clip named Right, it gives NullReferenceException : Object reference not set to an instance of an object error
Here is the code :
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
tk2dAnimatedSprite anim;
// Use this for initialization
void Start () {
anim = GetComponent<tk2dAnimatedSprite> ();
}
// Update is called once per frame
void Update () {
if (!anim.IsPlaying ("Right"))
anim.Play("Right");
}
}
simply can't work why?
Please help guys.
Best regards.
image for my case : (http://s18.postimg.org/z3u7wh24p/error.jpg)
-
You're mixing up 2D Toolkit 2.0 & 1.9x -
The tk2dAnimatedSprite has been replaced by a tk2dSpriteAnimator - you can tell from the list of components on your gameobject.
You can pretty much replace tk2dAnimatedSprite -> tk2dSpriteAnimator in your script with this and everything will be good :)
-
Ahh thank you so much ! ;)