viernes, 28 de enero de 2022

Unreal Engine 4;

Unreal Engine 4

 Experimentando y probando este motor de videojuegos y sin tener ni idea, me atrebo a publicar un videojuego en unas horas, Primero de todo la descarga de mi version es de unas 13 GB, estube todo el domingo de la mañana para descargarlo, ya que no tengo 5g en mi telefono movil que es lo que utilizo para mi aficion de internet de aprendizaje de videojuegos. Las conexiones de mi movil son de 4g... En fin acostumbrado a Unity es un programa muy complejo el de Unreal Engine, pero ejercitar con el, creo que facilita la comprension de Unity. La version que utilizo no compila en html5, las anteriores parece ser que si y por problemas de memoria, o espacio, que se ve ocupaba mucha no esta en la version que utilizo yo. Creo que es muy superior visualmente Unreal engine que Unity, pero es una opinion personal porque solo soy un aficionado aprendiz. Cuando arranca el motor de juegos se pueden elegir varias plantillas de formatos de videojuego, de disparos en primera persona, de 2d tipo marcianitos, o completamente en blanco desde cero. Asta 14 modos e contabilizado. 

 


 

 Y bueno ire experimentando con este motor de vez en cuando, lo mas sencillo que se puede hacer sin tener ni idea, es un simple juego de bolos, empujar unas eferas los con la camara y usar el efecto de gravedad,,,Simulate Physics, para poder empujar las esferas...aqui un enlace de lo practicado en unas horas...... 

 https://gamejolt.com/games/BOLAS_AZULES_CUELALAS_TODAS/684368


 

Como se ve en la imagen, las opciones de compilación, empaquetado, de un nuevo videojuego, falta la de html5, creo la suprimieron por que gasta muchos recursos, pero por lo mínimo que e leído, esta disponible en versiones mas antiguas del Unreal Enguine.


 

En la siguiente imagen en la parte izquierda, salen volúmenes básicos para empezar a trastear con Unreal, cubos, esferas,cilindros, conos,y demás elementos que ya son mas complicados cuando se parte desde cero, en la imagen arrastro una esfera al escenario del videojuego, sale en color azul y ahora mostrare como cambiarle ponerle una textura


 

Aquí en la parte de abajo hay una carpeta desde la que seleccionaremos texturas y arrastraremos una a la esfera….y por cierto la esfera esta congelada en el aire porque no esta activado su Physics...Simulate Physics a la derecha de la imagen...

 


 
arrastrar con el mouse desde la textura a a la esfera......

 


 En esta imagen el detalle de la esfera flotando en el aire, congelada, al darle al play para probar el video juego.

Las demas estan en el suelo por la simulacion de gravedad...esto ocurre por no haberle clicado la opcion de  Physics...Simulate Physics 


 



jueves, 20 de enero de 2022

The-wolf-man-of-the-underground-iii-demo-6;

 

domingo, 16 de enero de 2022

¿como funciona un sistema de quitar puntos o vidas en Unity y al hacerlo cambie la escena?;

¿Como funciona un sistema de quitar puntos o vidas en

Unity y al hacerlo cambie la escena?...adjunto el script

 

  using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DISMINUYEPUNTOSYCAMBIALAESCENA : 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>



        // At the start of the game..
        void Start ()
        {


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

            // Set the count to zero 
            count = 10;

            // 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 = "";
        }


        void OnTriggerEnter(Collider other) 
        {


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



            {
                // Make the other game object (the pick up) inactive, to make it disappear
                other.gameObject.SetActive (false);///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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


                SetCountText ();
            }
        }

        // Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
        void SetCountText()
        {


            countText.text = "VIDAS: " + count.ToString ();
            // Check if our 'count' is equal to or exceeded 12
            if (count <= 1) 
                //if (count >= 99) 
            {
                // Set the text value of our 'winText'
            //    winText.text = "JUEGO COMPLETADO";

                //    Destroy (gameObject, 1.2f); 

                Application.LoadLevel (1);

            }
        }
    }

 

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

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

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

mismo script explicando las lineas..........

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DISMINUYEPUNTOSYCAMBIALAESCENA : 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>



        // At the start of the game..
        void Start ()
        {


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

            // PARTIENDO DE 10 VIDAS QUE IRAN DISMINUYENDO
            count = 10;

            // 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 = "";
        }


        void OnTriggerEnter(Collider other) 
        {

//GAMEOBJECT CON NOMBRE TAG "POMADA" QUE PRODUCIDA LA RESTA DE PUNTOS DE 1 EN 1
              if (other.gameObject.CompareTag ("pomada"))



            {
                // Make the other game object (the pick up) inactive, to make it disappear
                other.gameObject.SetActive (false);///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                // RESTA 1 PUNTO
                count = count - 1;


                SetCountText ();
            }
        }

        // Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
        void SetCountText()
        {


            countText.text = "VIDAS: " + count.ToString ();
            // CUANDO ES MENOR DE 1 PUNTO CAMBIA LA ESCENA
            if (count <= 1) 

                //if (count >= 99) 
            {
                // Set the text value of our 'winText'
            //    winText.text = "JUEGO COMPLETADO";

                //    Destroy (gameObject, 1.2f); 

                Application.LoadLevel (1);

            }
        }
    }


play!!!;

 

the-wolf-man-of-the-underground-iii-demo-4 Y demo 4...perfeccionando las agresiones de los guardias, perdiendo vida si me agreden, y destrozando una zona del ascensor desde donde salen los guardias para que dejen de salir y atacar al hombre lobo, tienes que golpear el cuadro eléctrico del ascensor 

 

 

viernes, 14 de enero de 2022

the-wolf-man-of-the-underground-iii-demo-3;


miércoles, 12 de enero de 2022

¿Como funciona un sistema de sumar puntos en Unity?;

¿Como funciona un sistema de sumar puntos en Unity?

En las capturas de pantalla se pueden ver los elementos que intervienen para dicha labor...como si fuera una receta de cocina lo voy a explicar….

Ingredientes….

1-Un script en c#.

2- Un Canvas con dos text.

3- Un collider con el trigger acribado en este caso una esfera que lo tiene el player el hombre lobo y que tendrá el contenido del script en C#.

4- Un Tag con un nombre inventado en este caso le llamamos ”MATA” y se lo aplicamos a los enemigos, al nombre del Tag me refiero y ellos a su vez un cubo por encima de su cabeza también con el trigger activado.

5- A continuación el script y video de referencia.

 


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AUMENTAPUNTOS : 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);///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                // 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 >= 111112) ////////7original
            {



            }
        }
    }


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

cambio de escena por colision y nombrado por tag el gameobject
------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class portoquedetaccambialaescena : MonoBehaviour {


        void Start () {

        }




        //void OnCollisionEnter (){


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


            if (collision.gameObject.tag == "pomada") {
                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);




            }
        }
    }



martes, 11 de enero de 2022

IA inteligencia artificial persecución de los enemigos;

 

IA inteligencia artificial persecución de los enemigos


 

Voy avanzando mi blog con lo que estoy haciendo en la clonación de enemigos que me persiguen y destruyo de un zarpazo, el resultado es medio satisfactorio, falta pulir mucho, pero voy contando en el blog, en el video se ven imágenes de unos personajes medio trabajados que arian de vigilantes de seguridad y que irían persiguiendo al hombre lobo, este a su vez da unos zarpazos y les va arrancando la cabeza, también hay una mujer a la que se le acerca y de un zarpazo le arranca la cabeza.



1-el primer paso a sido poner un origen de las clonaciones de los personajes guardias de seguridad,

se van creando continuamente y les e puesto un Nav Mesh Agent.

2-E preparado el terreno, en este caso es un cubo que hace de suelo modelado con esa forma y desde el que puse la navegation...ver imagen


 

creí solo se podía hacer esto en un terreno típico de Unity pero yo lo echo partiendo de un cubo.

3- Un dato importante, los guardias no parten de base de las clonaciones, la base es un cubo que hace de padre sobre el que va el personaje de hijo el mismo guardia de seguridad en si mismo, e tenido que hacerlo así por que cuando iban apareciendo en cadena uno de tras del otro se auto destruían y aparecía el mismo personaje que no tiene cabeza y esta decapitado, porque los guardias tienen el script del actibate trigger que produce este cambio, e probado cambiar la velocidad de su Nav Mesh Agent. Para que no se tocasen entre si al ir clonándose pero no me funciono,




 



En la imagen se ven los personajes que están en prefabricado, la cabeza suelta, el cuerpo decapitado son los que aparecen con el script de ActivateTrigger, al colisionar el zarpazo en la parte de la cabeza del guardia, como se ve en el video de YouTube, desde luego aun falta muchísimo trabajo y muchísima practica del tema y aprendizaje...pero empiezo a construir unos personajes que me persiguen amenazadoramente, a esto e de añadirle un sistema de puntuación pero lo explicare mas adelante ademas de un sistema de vidas que valla perdiendo el hombre lobo si le atacan los guardias…..

.....................scripts ............................................


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

public class persecuciondeenmigoasiento2 : MonoBehaviour {


        Transform player;

        UnityEngine.AI.NavMeshAgent nav;


        void Awake ()
        {


            player = GameObject.FindGameObjectWithTag ("asiento2").transform;


            nav = GetComponent <UnityEngine.AI.NavMeshAgent> ();
        }


        void Update ()
        {

            nav.SetDestination (player.position);
    
        }
    }

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

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

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

para que no se ralentice el videojuego y liberar memoria el script de abajo

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



using System;
using UnityEngine;

namespace UnityStandardAssets.Utility
{
    public class TimedObjectDestructor : MonoBehaviour
    {
        [SerializeField] private float m_TimeOut = 1.0f;
        [SerializeField] private bool m_DetachChildren = false;


        private void Awake()
        {
            Invoke("DestroyNow", m_TimeOut);
        }


        private void DestroyNow()
        {
            if (m_DetachChildren)
            {
                transform.DetachChildren();
            }
            DestroyObject(gameObject);
        }
    }
}

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

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

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

using System;
using UnityEngine;
using Object = UnityEngine.Object;

namespace UnityStandardAssets.Utility
{
    public class ActivateTrigger : MonoBehaviour
    {
        // A multi-purpose script which causes an action to occur when
        // a trigger collider is entered.
        public enum Mode
        {
            Trigger = 0,    // Just broadcast the action on to the target
            Replace = 1,    // replace target with source
            Activate = 2,   // Activate the target GameObject
            Enable = 3,     // Enable a component
            Animate = 4,    // Start animation on target
            Deactivate = 5  // Decativate target GameObject
        }

        public Mode action = Mode.Activate;         // The action to accomplish
        public Object target;                       // The game object to affect. If none, the trigger work on this game object
        public GameObject source;
        public int triggerCount = 1;
        public bool repeatTrigger = false;


        private void DoActivateTrigger()
        {
            triggerCount--;

            if (triggerCount == 0 || repeatTrigger)
            {
                Object currentTarget = target ?? gameObject;
                Behaviour targetBehaviour = currentTarget as Behaviour;
                GameObject targetGameObject = currentTarget as GameObject;
                if (targetBehaviour != null)
                {
                    targetGameObject = targetBehaviour.gameObject;
                }

                switch (action)
                {
                    case Mode.Trigger:
                        if (targetGameObject != null)
                        {
                            targetGameObject.BroadcastMessage("DoActivateTrigger");
                        }
                        break;
                    case Mode.Replace:
                        if (source != null)
                        {
                            if (targetGameObject != null)
                            {
                                Instantiate(source, targetGameObject.transform.position,
                                            targetGameObject.transform.rotation);
                                DestroyObject(targetGameObject);
                            }
                        }
                        break;
                    case Mode.Activate:
                        if (targetGameObject != null)
                        {
                            targetGameObject.SetActive(true);
                        }
                        break;
                    case Mode.Enable:
                        if (targetBehaviour != null)
                        {
                            targetBehaviour.enabled = true;
                        }
                        break;
                    case Mode.Animate:
                        if (targetGameObject != null)
                        {
                            targetGameObject.GetComponent<Animation>().Play();
                        }
                        break;
                    case Mode.Deactivate:
                        if (targetGameObject != null)
                        {
                            targetGameObject.SetActive(false);
                        }
                        break;
                }
            }
        }


        private void OnTriggerEnter(Collider other)
        {
            DoActivateTrigger();
        }
    }
}