- Home /
Question by
MrSplosion · Aug 08, 2011 at 07:25 PM ·
animation2dspriteanimate
Sprite Animation
So I have this script that isn't working the way I want it to and I don't know why. I'm trying to make a script that offsets the sprite texture for an animation effect, but instead of activating every 1 second (that's what the "time" variable is set to) it waits a seconds then activates uncontrollably.
var time : float; // this is set to 1 btw
function Update(){
//if D is pressed
if(Input.GetAxis("left/right") < 0 && !IsInvoking("Animate")){
Invoke("AnimateRight", time);
}
}
function AnimateRight(){
//change back to zero to avoid sloppyness
if(renderer.material.mainTextureOffset.x >= 0.8){
renderer.material.mainTextureOffset.x = 0.0;
}
//increase offset
else{
renderer.material.mainTextureOffset.x += 0.1;
}
}
Can someone help? Thanks.
Comment