how to stop my scene on collision..

Hi! i have script in which we create the endless track , 1st end 2nd starts, 2nd end then 1st start again in a linklist… and these tracks are moving toward my player which seems like it’s running. what i want is on collision stop the track movement and player play an animation. in my below script
“foreach(Transform road in roads) {
road.Translate(0,0, -10f * Time.deltaTime);
}” this one stop and start the movement …
kindly help me out please :frowning: … i am not good in c# …

using UnityEngine;
using System.Collections.Generic;

public class MoveRoad : MonoBehaviour {
	
	public Transform prefab;
	
	private LinkedList<Transform> roads = new LinkedList<Transform>();
	
	private float posY = 0.0f;
	private int numberOfRoads = 5;

	// Use this for initialization
	void Start () {
		
		// Init the scene with some road-pieces
		for(int i=0;i < numberOfRoads;i++) {
			Transform road = Instantiate(prefab) as Transform;
			road.Translate(0, posY, i * road.localScale.z);
			roads.AddLast(road);
		}
	}
	
	// Update is called once per frame
	void Update ( ) {
			
		Transform firstRoad = roads.First.Value;
		Transform lastRoad = roads.Last.Value;
		
		// Create a new road if the first one is not 
		// in sight anymore and destroy the first one
		if(firstRoad.localPosition.z < -40f) {
			roads.Remove(firstRoad);
			Destroy(firstRoad.gameObject);
			
			Transform newRoad = Instantiate(prefab, new Vector3(0, posY ,
			                                                    lastRoad.localPosition.z + lastRoad.localScale.z), 
			                                Quaternion.identity) as Transform;
			roads.AddLast(newRoad);
			
		}

		// Move the available roads along the z-axis
		foreach(Transform road in roads) {

			road.Translate(0,0, -10f * Time.deltaTime);
		}
	}

	
	//////////Collision Here////////////

	void OnCollisionEnter(Collision collision) {

		if (collision.gameObject.tag == "Hardle") {
			print("Collision-moveRoad");
			animation.CrossFade("jump_pose", 0.02F);
			//animation.Play("idle");

	//		Time.timeScale= 0.0f;


		}
	}
}

I would sugget making a Bool that you could call moveRoads and set that to true,
Upon collision, set it to false.

in the update where the roads are moved, check if moveRoads is true and move the roads if it is.

// Move the available roads along the z-axis
foreach(Transform road in roads) 
{
	//Only move the roads if the moveRoads is true.
	if(moveRoads)
	{
		road.Translate(0,0, -10f * Time.deltaTime);
	}
}