private void SpawnObstacle() { var idx = (int)Random.Range(0, MovingObstaclePrefabs.Count - 1); var spawn = groundGenerator.GetSpawnLocation(); var g = Instantiate(MovingObstaclePrefabs[idx], spawn.transform.position, Quaternion.identity, null); var moving = g.GetComponent <MovingObstacle>(); moving.Direction = spawn.DestinationDirection; moving.UpdateTraits(); activeObstacles.Add(moving); }