Unity 3D Make Mystery Box Tutorial20153

Advertisemen

Unity 3D Make Mystery Box
Spawn random prefab on trigger enter







































DIRECT DOWNLOAD HERE



























THIS IS BACKUP  IN TEXT FORM

1. Create New C# and name it : itemSpawner


2. Copy & Past this text and save C# :
----------------------------------------­­­­­------------------------------------­-­-­-­-­-


using UnityEngine;
using System.Collections;

public class itemSpawner : MonoBehaviour {



bool hasSpawned = false;
public GameObject[] itemPrefabs;

void OnTriggerEnter(Collider other)
{
if(other.tag == "Player")
{
if(!hasSpawned)
{
hasSpawned = true;
Spawn();

}
}
}

void Spawn()
{

Instantiate(itemPrefabs[Random.Range(0,itemPrefabs.Length)],transform.position, transform.rotation);
}
}






 ----------------------------------------­­­­­------------------------------------­-­-­-­-­-













Advertisemen

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Tutorial Unity 3D