- Home /
Question by
nicolas1420 · Jul 27, 2014 at 09:18 PM ·
textureflip
fliping texture through script issue
here is a script that i grabed from the web and then modified to make it flip the texture when it changes direction the thing is it doesnt flip
any ideas?
#pragma strict
var dir : int;
var SwitchTime : float;
var hSpeed : float;
var X: float ;
X = -12;
function Start(){
X = transform.localScale.x;
}
function Update () {
if(dir == 1)
{
GoRight();
}
if(dir == 2)
{
GoLeft();
}
}
function GoRight()
{
this.gameObject.transform.position.x += hSpeed * Time.deltaTime;
yield WaitForSeconds(SwitchTime);
dir = 2;
}
if (GoRight){
transform.localScale.x = X;
}
function GoLeft()
{
this.gameObject.transform.position.x -= hSpeed * Time.deltaTime;
yield WaitForSeconds(SwitchTime);
dir = 1;
}
if (GoLeft){
transform.localScale.x = -X;
}
Comment