- Home /
How to translate object one movement with script
Hi, I need some help on this. How do I translate the object only one time? code below got 2 problem, first I can't put the FixedUpdate function inside If else. help me please..thanks in advance
static var callerPath = false;
if(callerPath == true){
function FixedUpdate () {
transform.Translate(0,10,0);
}
}
else if (callerPath ==false){
//transform opposite way }
Answer by FLASHDENMARK · Aug 23, 2011 at 05:49 PM
Not quiet sure what you are trying to obtain but, nonetheless why don't you just turn it around?
Something like this:
static var callerPath = false;
function FixedUpdate (){
if(callerPath) // You dont need to type: == true when you are checking if it is true.
transform.Translate(0,10,0);
}
else{
transform.Translate(0,-10,0);
}
}
I am not a 100% sure what you want but, this is properly a step in the right direction.
Thanks, I didnt think of that but I got an error say expecting EOF but found else on the line of the "ELSE" in the IF ELSE statement. Any idea? thanks
sorry, it still don't go the wanted it to be...I want that object to translate up on y axis for 10 unit then stop...this method will just keep translate non stop.
this method translates every frame that callerPath
is true
if you put callerPath = false
inside the if statement then when it tries to run next frame it will see callerPath
is false
and skip over the insides of the if statement