- Home /
Question by
GhandiJones · Dec 16, 2012 at 03:46 AM ·
javascriptpositionupdatedelaytween
Weird delay on Tween
Okay... I've run this both ways. The uncommented code works with 0 delay between the tweens. Which is how I want it to work, however, I am unable to check for starting position of the gameObject and send it the right direction, initially. The commented out section is what I'm working on, and works, however... there is a delay once it hits the 8 or -8 that I can not seem to work out where this is coming into play.
var factoryPos :boolean; //Position of the factory True = Right, False = Left
//Called once to initialize the tween
function Start() {
//Moves our factory back and forth
while(true){
onSpawnMove(true);
yield new WaitForSeconds(1.0);
onSpawnMove(false);
yield new WaitForSeconds(1.0);
}
}
//function Update(){
//
// GetFactoryPos();
//
// if(factoryPos == true){
//
// iTween.MoveTo(gameObject,{"x":8, "time":2});
//
// }else{
//
// iTween.MoveTo(gameObject,{"x":-8, "time":2});
//
// }
//
//}
//Sets up the function for the tween
function onSpawnMove(on){
if(on){
iTween.MoveTo(gameObject,{"x":8, "time":3});
}else{
iTween.MoveTo(gameObject,{"x":-8, "time":3});
}
}
//function GetFactoryPos(){
//
// if(gameObject.transform.position.x == 8){
//
// factoryPos = false;
//
// }
//
// if(gameObject.transform.position.x == -8){
//
// factoryPos = true;
//
// }
//
//}
Any feedback or help would be greatly appreciated.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613085506im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Android touch is not dynamic 1 Answer
"Script error: Update() can not be a coroutine.", please help 1 Answer
Problem with restarting the scene (js) 2 Answers
Mecanim 1 frame delay [solved] 2 Answers
Javascript Class Update 2 Answers