Prefab spawner doesnt work
So i am pretty new on Unity and i found this tutorial
https://www.youtube.com/watch?v=HIsEqKPoJXM&list=PLLH3mUGkfFCXps_IYvtPcE9vcvqmGMpRK∈dex=7
and i tried to make the same process on my android game project but nothing happened.I think my problem is about the cylinder.Because i am using cylinder instead of tile.I will be so glad if you guys help me.Here is my map;
[url=https://hizliresim.com/XEoDz6][img]https://i.hizliresim.com/XEoDz6.png[/img][/url]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CylinderManager : MonoBehaviour
{
public GameObject[] cylinderPrefabs;
private Transform playerTransform;
private float spawnZ = 0.0f;
private float cylinderLength = 30.0f;
private int amnCylindersOnScreen = 7;
// Use this for initialization
private void Start () {
playerTransform = GameObject.FindGameObjectWithTag ("Player").transform;
for (int i = 0; i < amnCylindersOnScreen; i++)
{
SpawnTile ();
}
}
// Update is called once per frame
private void Update () {
if (playerTransform.position.z > (spawnZ - amnCylindersOnScreen * cylinderLength))
{
SpawnTile ();
}
}
private void SpawnTile(int prefabIndex = -1)
{
GameObject go;
go = Instantiate (cylinderPrefabs [0]) as GameObject;
go.transform.SetParent (transform);
go.transform.position = Vector3.forward * spawnZ;
spawnZ += cylinderLength;
}
}
SOLUTION
Answer by JeffJason · Sep 28, 2017 at 02:33 PM
Let me give more information about my project.The player moves on the z-axis with a static velocity.And ı am controlling the x and y movements with input.acceleration command.Code still doesnt work i really need your help guys.This is a new ss from my project;
Your answer
![](https://koobas.hobune.stream/wayback/20220612135748im_/https://answers.unity.com/themes/thub/images/avi.jpg)