Desactive a object

Hi guys,

I doing a animated background.
Basically when the object reaches the position.x is desactived.

But this sprite that i’m working now, don’t move.
So i need that the animation occur one time, then the objective is desactived.

I’m using the code below for now…

Obs: Tamanho = SCALE

Thanks!

var speed : float;
var bloco : GameObject;
var maxposition : float;
var maxScale: int;
var minScale: int;
var tamanho: float;


function Start () {

}

function Update () {
	tamanho = Random.Range(maxScale, minScale);
	transform.localScale = new Vector3 (tamanho, tamanho,0);
	transform.position += new Vector3(speed, 0, 0) * Time.deltaTime;
		if (transform.position.x > maxposition)
			{
			bloco.SetActive(false);
			}
			
		}

You need to declare the float number “X” maxposition to deactivate GameObject named bloco.

You can declared it on function Start() and set the float number.

You need to declare float and int of speed, maxScale, minScale and tamaño.

Hope it will helpfully to you.

Regards.