Opposite direction in Trigger Enter

I have so many gameobjects in the scene.

The gameobjects moving by using TRANSLATE function.

transform.Translate(direction * Time.deltaTime * speed);

In trigger enter the objects should move in opposite direction

How can i do it??

Add a variable at the top of the file. I call it ‘forback’ for forwards and backwards:

var forback = 1.0;

Then your Translate() becomes:

transform.Translate(forback * direction * Time.deltaTime * speed);

Then to reverse the direction:

function OnTriggerEnter() {
	forback = -forback;
	Debug.Log("Entered the trigger");
}

Your character will need a Rigidbody to make this work.