I need help as I am unable to spawn a prefab on my game objects position. Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Puzzle : MonoBehaviour
{
private List<GameObject> _listeTraps;
[SerializeField] private GameObject[] _tableauTraps;
[SerializeField] private GameObject[] _Spikes;
[SerializeField] private GameObject[] _Mines;
[SerializeField] private GameObject[] _Nothing;
// Start is called before the first frame update
void Start()
{
_listeTraps = new List<GameObject[]>();
_listeTraps.Add(_Spikes);
_listeTraps.Add(_Mines);
_listeTraps.Add(_Nothing);
Init();
}
private void Init(){
for(int i = 0; i < _tableauTraps.Length; i++)
{
int _aleatoireSorte = Random.Range(0, _listeTraps.Count); //pige un chiffre random
GameObject[] n = _listeTraps[_aleatoireSorte]; //n = au chiffre piger
int _aleatoireTrap = Random.Range(0, n.Length);
_tableauTraps *= n[_aleatoireTrap];*
Instantiate(n[_aleatoireTrap]).transform.position = _tableauTraps*.transform.position;
// _listeTraps.RemoveAt(aleatoireSorte);
_}*
}
}
And here are a couple of screenshots showing my unity editor:
[189887-189776-screenshot.png|189887]_
This is what actually happens when I spawn my prefab:
_[189888-189779-capture2.png*|189888]*
_*
_*