I’m making 2d racing game …
and I’m using UI image in the canvas background (road) .my car and enemy cars
and I have tried to instantiate enemy car with this script by attaching this script to empty gameObject then attaching the enemy prefab to the enemyCar image that in the script…but the strange thing is :the enemyCar is instantiated in the hierarchy but I can’t see it in the game
What is the wrong ?
is the wrong related to the child and parent or what ?
and how can I make that UI image a child o canvas in the script ?
using UnityEngine;
using UnityEngine.UI;
public class Generate : MonoBehaviour
{
public Image enemyCar;
// Use this for initialization
void Start()
{
InvokeRepeating("CreateEnemy", 1f, 1.5f);
}
void CreateEnemy()
{
Instantiate(enemyCar);
}
}