Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- using UnityEngine;
- using System;
- using System.Collections.Generic; //Allows us to use Lists.
- using Random = UnityEngine.Random;
- using System.Collections;
- public class MonstruoRandom : MonoBehaviour
- {
- [Header("Aqui el Prefab del portal con el monstruo")]
- public GameObject prefab;
- public GameObject PrefabInstanciado;
- [Header("El valor entero por ej 1 es un segundo")]
- public float TiempoDeAparicion= 500f;
- float Tiempo;
- public bool MonstruoEnEscena = false;
- // Instantiate the Prefab somewhere between -10.0 and 10.0 on the x-z plane
- void Start () {
- Tiempo = TiempoDeAparicion;
- }
- void Update () {
- Tiempo -= Time.deltaTime * 1;
- PrefabInstanciado = GameObject.Find ("MonstruoPrefab(Clone)");
- if (PrefabInstanciado != null){
- MonstruoEnEscena = true;
- }else{
- MonstruoEnEscena = false;
- }
- if (Tiempo <= 0f){
- StartCoroutine (Aparicion ());
- Tiempo += TiempoDeAparicion;
- }
- }
- IEnumerator Aparicion () {
- yield return new WaitForSeconds (2);
- if (!MonstruoEnEscena) {
- Vector3 position = new Vector3 (Random.Range (-10.0f, 10.0f), 0, Random.Range (-10.0f, 10.0f));
- prefab.transform.name = "MonstruoPrefab";
- Instantiate (prefab, position, Quaternion.identity);
- }
- }
- }
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
- ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement