sábado, 26 de febrero de 2022

Pinball detalles con C# game over reinicios de juego y de pantallas niveles del videojuego;

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DESTRUYEYPASAANIVEL3 : MonoBehaviour {


        void Start () {

            //tickSource = GetComponent<AudioSource> ();



        }

        void Update () {
        }

        void OnTriggerEnter(Collider other) {
            //if (other.gameObject.CompareTag ("avismo")){
            //if (other.gameObject.CompareTag ("ogri2")){
            if (other.gameObject.CompareTag ("juegopierdo")){
                //transform.Rotate (new Vector3 (0 * Time.deltaTime, 91, 90), Space.Self);

                //tickSource.Play ();
                Destroy (gameObject, 2.0f); 



                    Application.LoadLevel (3);/////7originalllllllllllllllllllllllllllll



            }}

    }

 ------------------------------------------------------------------------------------------------------

 

 -----------------------------------------------------------------

----------

  using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;/// <summary>
public class reiniciojuego2 : MonoBehaviour {


        public Text contador1;
        public Text fin1;
        private float tiempo = 8f;


//    void Awake() {

    //}

        // Use this for initialization
        void Start () {
            contador1.text = " " + tiempo;
            fin1.enabled = false;

        }

        // Update is called once per frame
        void Update ()
        {
        
            tiempo -= Time.deltaTime;
            contador1.text = " " + tiempo.ToString ("f0");
            if (tiempo <= 0) {
                contador1.text = "0";
                fin1.enabled = true;

                {
                    //void OnTriggerEnter(Collider other) {
                    //if (other.gameObject.CompareTag ("ogri2 (1)CAMPEONNNNNNNNNNNNNNNNNNN")){

                //    Destroy (gameObject, 0.0f); 

                    {

                        //Application.LoadLevel (1); ESTE ES EL ORIGINALLLLLLL

                        Application.LoadLevel (0);

                    }
                }
            }
        }

    }
---------------------------------------------------------------------

Detalles que se me olvido comentar en el video son por ejemplo un bug que tenia cuando la bola salia pitando como una bala y no retornaba a sus coordenadas por que no tocaba los gameobjects que producían esa accion, lo resolví poniendo un enorme cubo de color negro de fondo y aplanado como un plano con el correspondiente tag “cordena”, así la bola hiciese lo que hiciese si se salia del juego daba hay y volvia a sus coordenadas…..también añado el script que tiene la escena de gameover para que transcurridos 8 segundos se reinicie el juego si se pierden las 3 bolas…...