- Home /
Moving Platform
I'm having trouble getting a moving platform in my game to work. But my code will not work. Also open to alternate ideas for same effect.
var xloc : float = 20; var direction : int = 1;
function FixedUpdate (){ if(direction ==1) { transform.position.x +=xloc Time.deltaTime; if(transform.position.x <= 128.0){ dirction==2; } if(direction ==2) { transform.position.x -=xloc Time.deltaTime; if(transform.position.x >= 77.0){ dirction==1; } }
format your code, you might get a more positive response.
might be easier to make an animation, or use iTween(that's just my personal preference tho).
If you do want to stick with transform.position, format your code and I'm sure someone can help you.
*to format code, highlight your code and press the small square box with 1's and 0's in it.
*edit