Shutting a function when another function calling.

Hey everyone, I want to shut a function when I call another function, better for you to understand my code here,

var speed = 5.0f;
function Update () {
	Normal();
}

function OnCollisionEnter(col : Collision){
	if(col.gameObject.name == "LeftWall"){
		transform.position.x += 30 * Time.deltaTime;
	}
}

function Normal(){
	transform.position.x -= speed * Time.deltaTime;
}

So How I do it :slight_smile:

Use bool checking, like so:

var isCollided = false;
var speed = 5.0f;
function Update () {
    Normal();
}
 
function OnCollisionEnter(col : Collision){
    if(col.gameObject.name == "LeftWall"){
        transform.position.x += 30 * Time.deltaTime;
        isCollied = true;
    }
}
 
function Normal(){
    if (!isCollided){
        transform.position.x -= speed * Time.deltaTime;
    }

}