I’m writing a script for touch screen input in which the player character will be animated through 2D Toolkit when a GUI button is touched. This is my script so far, and I can’t seem to work out how to get it to work.
Each time I drag the character I want to animate into the “Animated Sprite” variable of the inspector, it resets to “None” at runtime.
The rest of the code involving the player having rigidbody.drag changed to 3.000 works perfectly. The keyboard version of this script works as well. Can anyone help?
My code so far is:
var Player : GameObject;
var animatedSprite : tk2dAnimatedSprite;
animatedSprite = gameObject.GetComponent(tk2dAnimatedSprite);
function Update () {
var fingerCount = 0;
for (var touch : Touch in Input.touches) {
if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled && guiTexture.HitTest(touch.position))
fingerCount++;
}
if (fingerCount > 0) {
Player.rigidbody.drag = 3.000;
animatedSprite.Play("Jumped");
animatedSprite.animationCompleteDelegate = null;
}
}