Advertisement
Diamond32_Tutoriales

MonstruoRandom

Jul 19th, 2020
1,644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  2. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  3. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  4. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  5. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  6. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  7. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  8. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  9.  
  10. using UnityEngine;
  11. using System;
  12. using System.Collections.Generic;       //Allows us to use Lists.
  13. using Random = UnityEngine.Random;
  14. using System.Collections;
  15.  
  16. public class MonstruoRandom : MonoBehaviour
  17. {
  18.     [Header("Aqui el Prefab del portal con el monstruo")]
  19.     public GameObject prefab;
  20.     public GameObject PrefabInstanciado;
  21.     [Header("El valor entero por ej 1 es un segundo")]
  22.     public float TiempoDeAparicion= 500f;
  23.     float Tiempo;
  24.     public bool MonstruoEnEscena = false;
  25.  
  26.  
  27.     // Instantiate the Prefab somewhere between -10.0 and 10.0 on the x-z plane
  28.  
  29.     void Start () {
  30.         Tiempo = TiempoDeAparicion;
  31.     }
  32.  
  33.     void Update () {
  34.         Tiempo -= Time.deltaTime * 1;
  35.         PrefabInstanciado = GameObject.Find ("MonstruoPrefab(Clone)");
  36.  
  37.         if (PrefabInstanciado != null){
  38.             MonstruoEnEscena = true;
  39.         }else{
  40.             MonstruoEnEscena = false;
  41.         }
  42.  
  43.  
  44.         if (Tiempo <= 0f){
  45.             StartCoroutine (Aparicion ());
  46.             Tiempo += TiempoDeAparicion;
  47.         }
  48.     }
  49.  
  50.  
  51.     IEnumerator Aparicion () {
  52.         yield return new WaitForSeconds (2);
  53.         if (!MonstruoEnEscena) {
  54.             Vector3 position = new Vector3 (Random.Range (-10.0f, 10.0f), 0, Random.Range (-10.0f, 10.0f));
  55.             prefab.transform.name = "MonstruoPrefab";
  56.  
  57.             Instantiate (prefab, position, Quaternion.identity);
  58.         }
  59.     }
  60. }
  61. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  62. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  63. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  64. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  65. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  66. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  67. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  68. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
  69. ///////////////SCRIPTS BY DIAMOND32 TUTORIALES////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement