miércoles, 23 de febrero de 2022

C# niveles con unity;

 


En breves instantes video explicativo........

  using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AUMENTAPUNTOSP : MonoBehaviour {

        // Create public variables for player speed, and for the Text UI game objects
        public float speed;
        public Text countText;
        public Text winText;

        // Create private references to the rigidbody component on the player, and the count of pick up objects picked up so far
        private Rigidbody rb;
        private int count;/// <summary>

        void Start ()
        {


            // Assign the Rigidbody component to our private rb variable
            rb = GetComponent<Rigidbody>();

            // Set the count to zero 
            count = 0;

            // Run the SetCountText function to update the UI (see below)
            SetCountText ();

            // Set the text property of our Win Text UI to an empty string, making the 'You Win' (game over message) blank
            winText.text = "";
        }

        // store a reference to that collider in a variable named 'other'..
        void OnTriggerEnter(Collider other) 
        {

            //if (other.gameObject.CompareTag ("ogri2"))
            if (other.gameObject.CompareTag ("MATA"))
        //if (other.gameObject.CompareTag ("lateral"))
            {

                // Make the other game object (the pick up) inactive, to make it disappear
//                other.gameObject.SetActive (false);////ESTO DE AQUI SI ESTA ACTIVADO BORRA EL GRAFICO GIRATORIO MUY OMPORTANTISIMO

                // Add one to the score variable 'count'
                count = count + 1;


                // Run the 'SetCountText()' function (see below)
                SetCountText ();
            }
        }

        // Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
        void SetCountText()
        {
            // Update the text field of our 'countText' variable
            //countText.text = "Count: " + count.ToString ();

            countText.text = "PUNTOS: " + count.ToString ();
            // Check if our 'count' is equal to or exceeded 12
            //if (count == 11) 
                //if (count >= 11) /////////original
                if (count >= 44) ////////7original
            {

        //    Destroy (gameObject);

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

            }
        }
    }


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

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

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


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AUMENTAPUNTOSPlateral : MonoBehaviour {

        // Create public variables for player speed, and for the Text UI game objects
        public float speed;
        public Text countText;
        public Text winText;

        // Create private references to the rigidbody component on the player, and the count of pick up objects picked up so far
        private Rigidbody rb;
        private int count;/// <summary>

        void Start ()
        {

            // Assign the Rigidbody component to our private rb variable
            rb = GetComponent<Rigidbody>();

            // Set the count to zero 
            count = 44;

            // Run the SetCountText function to update the UI (see below)
            SetCountText ();

            // Set the text property of our Win Text UI to an empty string, making the 'You Win' (game over message) blank
            winText.text = "";
        }

        // store a reference to that collider in a variable named 'other'..
        void OnTriggerEnter(Collider other) 
        {

            //if (other.gameObject.CompareTag ("ogri2"))
            //if (other.gameObject.CompareTag ("MATA"))
        if (other.gameObject.CompareTag ("lateral"))
            {


                // Make the other game object (the pick up) inactive, to make it disappear
//                other.gameObject.SetActive (false);////ESTO DE AQUI SI ESTA ACTIVADO BORRA EL GRAFICO GIRATORIO MUY OMPORTANTISIMO


                // Add one to the score variable 'count'
                count = count + 10;


                // Run the 'SetCountText()' function (see below)
                SetCountText ();
            }
        }

        // Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
        void SetCountText()
        {
            // Update the text field of our 'countText' variable
            //countText.text = "Count: " + count.ToString ();

            countText.text = "PUNTOS: " + count.ToString ();
            // Check if our 'count' is equal to or exceeded 12
            //if (count == 11) 
                //if (count >= 11) /////////original
                if (count >= 4) ////////7original
            {

        //    Destroy (gameObject);

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

            }
        }
    }




lunes, 21 de febrero de 2022

Como hacer un pinball con unity sin tener ni idea y asu vez meterlo en otro videojuego echo tambien sin tener ni idea.;

Como hacer un pinball con unity sin tener ni idea y asu vez meterlo en otro videojuego echo tambien sin tener ni idea.;

 

Videojuego THE WOLF MAN OF THE UNDERGROUND beta;

siguiendo este videojuego voy a insertar minijuegos en el, la idea es que en momentos dados el jugador que maneja al hombre lobo desconecte del entorno y se baya por ejemplo a un salón recreativo a jugar a la maquina del millón, la de pegarle a la bola y sumar puntos asta conseguir partidas extra,,,, en este caso seria avanzar en otros niveles del videojuego…..lo estoy haciendo así para ver si descanso del juego de su construcción y luego vuelvo a retomarlo alternando unos temas con otros y compaginándolos en el mismo videojuego de THE WOLF MAN OF THE UNDERGROUND

domingo, 13 de febrero de 2022

PINBALL SCRIPTS EN C# PARA CONSTRUIR EL VIDEOJUEGO;

 


 

 

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

public class empujafuerteportagestenombre : MonoBehaviour {



        // public float thrust;
        public Rigidbody rb;

        void Start()
        {
            rb = GetComponent<Rigidbody>();
        }

        void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.CompareTag("empujafuerte"))
            {

                rb.AddForce(0.0f, 0f, 177.0f, ForceMode.Impulse);


            }
        }


    }


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

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

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

public class altocartagcambialascoordenadas : MonoBehaviour {


        // Use this for initialization
        void Start()
        {

            //transform.rotation = Quaternion.Euler (0,45, 0);
        }



    void Update()
    {
    }

    //void OnCollisionEnter (Collision collision){
    //    if (collision.gameObject.tag == "PUYO modelo"){


    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("cordena"))
        {


            transform.position = new Vector3 (-38.5f,8.6f, -14.7f);


        }
    }

}

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

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


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

public class altocartaggiraluzfoco : MonoBehaviour {



        // Use this for initialization
        void Start()
        {

            //transform.rotation = Quaternion.Euler (0,45, 0);
        }


//    float x;/// imbentado


        void Update()
        {
        }

        //void OnCollisionEnter (Collision collision){
        //    if (collision.gameObject.tag == "PUYO modelo"){


        void OnTriggerEnter(Collider other)
        {
            //if (other.gameObject.CompareTag("luzgira"))
        if (other.gameObject.CompareTag("MATA"))
            {


                transform.position = new Vector3 (29.24f,38.13f, -60.19f);//////este funcionaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
            //transform.rotation = new Vector3 (-38.5f,8.6f, -14.7f);

            //transform.rotation = new Vector3  (0.4f, 5.1f, 1.1f);
            //transform.rotation = Quaternion.Euler (0, 5, 0);


            //x += Time.deltaTime * 0.2f;
             
        //    transform.rotation = Quaternion.Euler (x, 0, 0);


            }
        }

    }


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

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

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AUMENTAPUNTOSP : MonoBehaviour {

        // Create public variables for player speed, and for the Text UI game objects
        public float speed;
        public Text countText;
        public Text winText;

        // Create private references to the rigidbody component on the player, and the count of pick up objects picked up so far
        private Rigidbody rb;
        private int count;/// <summary>

        void Start ()
        {


            // Assign the Rigidbody component to our private rb variable
            rb = GetComponent<Rigidbody>();

            // Set the count to zero 
            count = 0;

            // Run the SetCountText function to update the UI (see below)
            SetCountText ();

            // Set the text property of our Win Text UI to an empty string, making the 'You Win' (game over message) blank
            winText.text = "";
        }

        // store a reference to that collider in a variable named 'other'..
        void OnTriggerEnter(Collider other) 
        {

            //if (other.gameObject.CompareTag ("ogri2"))
            if (other.gameObject.CompareTag ("MATA"))

            {








                // Make the other game object (the pick up) inactive, to make it disappear
//                other.gameObject.SetActive (false);////ESTO DE AQUI SI ESTA ACTIVADO BORRA EL GRAFICO GIRATORIO MUY OMPORTANTISIMO







                // Add one to the score variable 'count'
                count = count + 1;


                // Run the 'SetCountText()' function (see below)
                SetCountText ();
            }
        }

        // Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
        void SetCountText()
        {
            // Update the text field of our 'countText' variable
            //countText.text = "Count: " + count.ToString ();

            countText.text = "PUNTOS: " + count.ToString ();
            // Check if our 'count' is equal to or exceeded 12
            //if (count == 11) 
                //if (count >= 11) /////////original
                if (count >= 40) ////////7original
            {







            Application.LoadLevel (1);





            }
        }
    }



CONTINUARA......ESTA EN CONSTRUCCION.........................................................................

..........................

jueves, 10 de febrero de 2022

PINBALL.....rb.AddForce(10.3f, 0f, 10.3f, ForceMode.Impulse);


 

PINBALL.

Estoy haciendo ahora un videojuego para desconectar con el del hombre lobo o quizás complementarlo en alguna escena, pero mas adelante lo continuare a la vez que este del pinball.


Es un juego sencillisimo de varios niveles que se consiguen sumando puntuaciones.

Lo mas dificultoso a sido conseguir el rebote de la bola cuando choca con los elementos del videojuego, el rebote que la bola tenga vida, inercias y fuerzas que la empujan , y me vuelto medio loco buscando scripts en C # para conseguirlo, estoy muy orgulloso de haberlo conseguido y de mostrarlo aquí para el que quiera hacer un pinball o algo por el estilo, partiendo de los dos scripts de C# que e sacado del….

https://docs.unity3d.com/es/2018.4/ScriptReference/Rigidbody.AddForce.html


los scripts de la parte original que los copie me dieron la idea de que se ejerzan esas fuerzas pero no constantemente sino al tocar la bola elementos con el tag de “MATA”..

Es curioso como voy solucionando muchos temas con el tema de poner un tag personal a los gameobjects, sonidos, movimientos, suma de puntuaciones,cambiar de escenas o niveles, y ahora aplicar fuerzas de inercia……..




using System.Collections;

using System.Collections.Generic;

using UnityEngine;



public class ExampleClass : MonoBehaviour

{

// public float thrust;

public Rigidbody rb;


void Start()

{

rb = GetComponent<Rigidbody>();

}


void OnTriggerEnter(Collider other)

{

if (other.gameObject.CompareTag("MATA"))

{


rb.AddForce(10.3f, 0f, 10.3f, ForceMode.Impulse);



}

}



}



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

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

using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class EXAMPLEREBOTE2PERFECTO : MonoBehaviour

{


// public float thrust;

public Rigidbody rb;


void Start()

{

rb = GetComponent<Rigidbody>();

}


void OnTriggerEnter(Collider other)

{

if (other.gameObject.CompareTag("MATA"))

{


rb.AddForce(0.000003f, 0f, 0.000003f, ForceMode.Impulse);



}

}



}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ORIGINAL-------

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

System.Collections;

using System.Collections.Generic;

using UnityEngine;
public class ExampleClass : MonoBehaviour
{
    public float thrust;
    public Rigidbody rb;
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }
    void FixedUpdate()
    {
        rb.AddForce(transform.forward * thrust);
    }
}

----------------------------------------------------------ORIGINAL--------------


System.Collections;

using System.Collections.Generic;

using UnityEngine;
public class ExampleClass : MonoBehaviour
{
    public float thrust;
    public Rigidbody rb;
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }
    void FixedUpdate()
    {
        rb.AddForce(0, 0, thrust, ForceMode.Impulse);
    }
}
 
 
 
 



 
 
 
 

domingo, 30 de enero de 2022

Como hacer un menú de inicio con Unity sencillisimo;

 


Volviendo a Unity….

Un pequeño repaso, para ampliar mi blog con capturas de pantalla…

En mi videojuego ...The wolf man of the underground iii demo 6, voy a explicar paso a paso lo desarrollado y conseguido y los problemas que me ido topando e intentando resolver.

Estoy haciendo un menú de inicio del videojuego de una forma particular, en la captura de pantalla se ven los elementos del videojuego que intervienen.

Build Settings, donde hay cuatro escenas numeradas desde 0,1,2,3 y con las que vamos cambiando las escenas desde la 0, que es la del menú muy simple que e ideado yo y que voy a explicar a continuación.

Un cube de color negro con el rotulo START, con forma de ficha de domino.

Otro cubo con forma de cuadro con la textura de la ilustración de la cara del hombre lobo.

Cube (2)TRASPARENTE…..otro cubo con forma también de ficha de domino pero que le quitado el (mesh).

Y claro tenemos la cámara que enfoca desde arriba del todo.

Y dos scripts uno que provoca que al colisionar el elemento cube de color negro con el rotulo START, con el elemento Cube (2)TRASPARENTE…..otro cubo con forma también de ficha de domino pero que le quitado el (mesh).

Se cambia a la escena numero 1 donde empiezas a jugar,

Y otro script que de forma secundaria provoca la acción de gravedad del gameobject con el rotulo STARD este que tiene un tag if (collision.gameObject.tag == "auno") {
con el nombre “auno”, hace el cambio de la escena.

A continuación las capturas de pantalla unas 12 donde intento explicar el tema y las ultimas imágenes muy importantes que indican como se hace un tag para que funcione el script, el tag solo es un nombre inventado para el elemento del videojuego que interviene en la acción del cambio de escena.

También pongo los scripts de C# siempre, ya que java script no se utiliza ahora mismo en Unity


 










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

public class STARTTAG : MonoBehaviour {

        void Start () {

        }

        //void OnCollisionEnter (){

        void OnCollisionEnter (Collision collision)
        {
            //if (collision.gameObject.tag == "maloazul (4)") {
            //Destroy (gameObject, 0.0f); 

            if (collision.gameObject.tag == "auno") {
                //Destroy (gameObject, 2.0f); 

                //    transform.position = new Vector3 (198.301f, 20.316f, 136.023f);/////////nuebo mio
                //transform.Translate (new Vector3 (198 * Time.deltaTime, 20, 136.2f), Space.Self);/////////////IMBENTADO

                //Application.LoadLevel (1);////ORIGINALLLLLLLLLLLL
                Application.LoadLevel (1);

            }
        }
    }


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

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

aqui solo proboca de forma secundaria la gravedad para que caiga el gameobject sobre el otro y aga el cambio de escena al tocarlo por su nombre de tag----------

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

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

public class CAMBIAACEROALAPRETARRATONIZQUIERDO : MonoBehaviour {



        void Update ()
        {


            if (Input.GetKey(KeyCode.Space))////funciona contantemente al apretar W mayusculas a de ser

            transform.Rotate (new Vector3 (0 * Time.deltaTime, 0, 0), Space.Self);

            //if (Input.GetButton ("Fire1")) ORIGINALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
            if (Input.GetButtonDown("Fire1"))


        transform.Rotate (new Vector3 (0 * Time.deltaTime, 0, 0), Space.Self);


            //    Application.LoadLevel (1);



        }
    }