I want to make a 3D game where my character is on a straight road with cars spwaning from the right and move left at different speeds. I want to know how do I spawn a certain number of gameObjects randomly at different speeds and z axis positions between two waypoints.
Thanks
You should make two scripts. One Generate_cars to generate cars and second Car script.
In Car script you move your car with addforce or constant velocity or changing transform.position. Set speed and another variables for it. Assign this code to your car object and make prefab for it.
In Generate_cars script you generate cars in special times (intervals) using IEnumerator
and instantiate car prefabs into it.
class Generate_cars{
IEnumerator generate(){
GameObject carr;
While(true){
yield return new WaitForSeconds(5f);
carr=Instantiate(car_prefab) as GameObject;
}
}
}