domingo, 9 de octubre de 2022

Como cambiar el eje de un gameobject con Unity 2022.1.12f1 con el Pivot y con Center; Para hacer una puerta giratoria; C#;

 Me tirado varios meses para poder hacer una puerta giratoria y no recordaba como lo hacia antes por un problema de descentrar el eje del gameobject y ponerlo en un extremo; y lo e resuelto de casualidad, unas imagenes valen mas que 1000 palabras, asi que sin comentarios, a partir de aqui es muy sencillo hacer una puerta giratoria, ni script necesita, el player pasa y la puerta gira desde un extremo, no necesita nada mas en absoluto.





SCRIPTS EN C# QUE UTILIZO PARA HABRIR Y CERRAR LAS PUERTAS MEDIANTE UNA ANIMACION REALIZADA CON 2 DE ELLAS, SON PUERTAS GIRATORIAS Y UTILIZO 4 PUERTAS CON ESTOS 3 SCRIPTS CONSIGO SU FUNCIONAMIENTO CUANDO EL PLAYER CRUZA POR ELLAS....ESTE PARA LAS PUERTAS GIRATORIAS UN ESCRIPT PARA LA DE LA IZQUIERDA Y EL MISMO PARA LA DE LA DERECHA ARRASTRANDOLAS A SU CORRESPONDIENTE CASILLA QUE FABRICA EL SCRIPT.

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

public class activatTexto : MonoBehaviour
{
    public GameObject texto;

    private void OnTriggerEnter (Collider other)
    {
      if(other.tag == "Player")
        {
            texto.SetActive(true);
              

        }
    }
    private void OnTriggerExit(Collider other)
    {
        if (other.tag == "Player")
        {
            texto.SetActive(false);


        }
    }
}


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

ESTOS DOS PARA LAS PUERTAS CUANDO ESTAN CERRADAS.....

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

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

public class BORRAPUERTASQUIETASALPASAR : MonoBehaviour
{


    public GameObject puertagiratoriadesdeblenderCINCO;


    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {



            puertagiratoriadesdeblenderCINCO.SetActive(false);

        }
    }


    private void OnTriggerExit(Collider other)/////imbento
    {
                if (other.tag == "Player")///////imbento
             


        {
                 
                        puertagiratoriadesdeblenderCINCO.SetActive(true);

               
        }
}
}
    

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

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

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

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

public class BORRAPUERTASQUITASALPASARLASEIS : MonoBehaviour
{


    public GameObject puertagiratoriadesdeblenderSEIS;


    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {



            puertagiratoriadesdeblenderSEIS.SetActive(false);

        }
    }


    private void OnTriggerExit(Collider other)/////imbento
    {
        if (other.tag == "Player")///////imbento



        {

            puertagiratoriadesdeblenderSEIS.SetActive(true);


        }
    }
}

miércoles, 5 de octubre de 2022

PC DEMO 9 WESTERN GAY by TOZUDO;

 

 
trabajando el escenario escaleras por fuera y en el interior.....

lunes, 3 de octubre de 2022

sábado, 1 de octubre de 2022

Unity script en C# rota un gameobject al presionar rueda central del raton o mouse;

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

public class aspagiraapretarraton : MonoBehaviour
{


    // Use this for initialization
    void Start()
    {


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



    // Update is called once per frame
    void Update()

    {
        //void OnTriggerEnter(Collider other)
        {

            if (Input.GetButton("Fire3"))////// AMETRALLADORA AMETRAYADORA



            {
                // Es la rotacion de Angulos de Euler en grados.
                transform.Rotate(new Vector3(0 * Time.deltaTime, 0, 200), Space.Self);


            }
        }

    }
}

jueves, 29 de septiembre de 2022

demo 7 de western ;

 

Explicacion mas detallada de recogida de objetos con C# de unity;

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

public class creaenmano3 : MonoBehaviour
{
   

    public GameObject retra, pico;


    // private void Update()/////original
    //  {/////////////////original

    //  if (Input.GetKeyDown(KeyCode.Alpha1))/////original



    // {////original
    // hacha.SetActive(false);///original
    //   pico.SetActive(false);/////original
    //     }////original


    private void OnTriggerEnter(Collider other)/////imbento
    {
        if (other.tag == "Player")///////imbento
        {/////////////////////////////////////imbento





            //  if (Input.GetKeyDown(KeyCode.Alpha2))//////original
            {
                retra.SetActive(true);
                pico.SetActive(false);
            }
            //   if (Input.GetKeyDown(KeyCode.Alpha3))
            //   {
            //   hacha.SetActive(false);
            //   pico.SetActive(true);
        }
    }
}
// }///////////////////imbento




En esta imagen de arriba el cubo donde puse el script...

aqui con la flecha raton señalo el arma que tiene en un hueso de la mano el Player, esta desactivada, en las sucesivas imagenes se puede ver como la arrastro en la casilla que produce el script, y el script la activa cuando el player entra en la zona del cubo al igual que produce el texto del manejo de esta, funciona de la misma forma...

 

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

public class activatTexto : MonoBehaviour
{
    public GameObject texto;

    private void OnTriggerEnter (Collider other)
    {
      if(other.tag == "Player")
        {
            texto.SetActive(true);
              

        }
    }
    private void OnTriggerExit(Collider other)
    {
        if (other.tag == "Player")
        {
            texto.SetActive(false);


        }
    }
}

 

fijarse en el video y en las imagenes , 






en la imagen indico que hay que arrastrar con el raton el arma desactivada a la casilla producida por el script en C# que hace aparecer el arma en la mano del player, ......

utilizo tambien otro script que hace borrar la imagen del arma al tocarla el player y da la sensacion que la recoje....

 

 

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

public class destruyemetraportag : MonoBehaviour
{
   



    //public AudioSource tickSource;


    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("Player"))
        {
            //transform.Rotate (new Vector3 (0 * Time.deltaTime, 91, 90), Space.Self);

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


        }
    }

}

//}






martes, 27 de septiembre de 2022

C# DE UNITY; SCRIPTS ECHO POR MI, FIJANDOME EN APRENDIDOS POR INTERNET DE OTROS.;

 

😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁

 

 SCRIPTS MUY IMPORTANTES CREAN O RECOGEN UN ARMA ALPASAR POR UN SITIO Y AL DISPARAR PIERDEN MUNICION INDICADO POR UNA VARRA DE MUNICION EN LUGAR DE VIDA, ASTA QUE ESTA DESAPARECE AL NO TENER MUNICION

 

 

 

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

 

 SCRIPT ECHO POR MI, FIJANDOME EN APRENDIDOS POR INTERNET DE OTROS.

APRIETAS EL RATON Y MENGUA LA BARRA DE MUNICION DEL ARMA ASTA DESAPARECER

 

 

 

 

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


    //    public int cura;
    public int damage;
    public int vidaEnemigo;
    public Slider BarraVidaEnemigo;


    void Update()
    {

        BarraVidaEnemigo.value = vidaEnemigo;

    }


    void OnTriggerEnter(Collider other)
    {
        //if (other.gameObject.CompareTag ("MATA")){
        
        //if (other.gameObject.CompareTag("Player"))
            if (Input.GetButton("Fire3"))////// AMETRALLADORA AMETRAYADORA
            {

            vidaEnemigo -= damage;



            if (vidaEnemigo <= 0)

                DestroyObject(gameObject);///IMBENTADO

            {




                //Application.LoadLevel (3);////original 16-6-22

                //Application.LoadLevel (10); ////prueba ORIGINAL DE 22-6-22
                //    Application.LoadLevel (1); ////prueba
                //    Application.LoadLevel(0); ////prueba ORIGINAL DE 26-7-22

            }
        

        }
    }

}


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

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

 SCRIPT ECHO POR MI, FIJANDOME EN APRENDIDOS POR INTERNET DE OTROS.

PASAS POR UN CUBO Y SE ACTIBA UN ARMA EN LA MANO

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

 

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

public class creaenmano3 : MonoBehaviour
{
   

    public GameObject retra, pico;


    // private void Update()/////original
    //  {/////////////////original

    //  if (Input.GetKeyDown(KeyCode.Alpha1))/////original



    // {////original
    // hacha.SetActive(false);///original
    //   pico.SetActive(false);/////original
    //     }////original


    private void OnTriggerEnter(Collider other)/////imbento
    {
        if (other.tag == "Player")///////imbento
        {/////////////////////////////////////imbento





            //  if (Input.GetKeyDown(KeyCode.Alpha2))//////original
            {
                retra.SetActive(true);
                pico.SetActive(false);
            }
            //   if (Input.GetKeyDown(KeyCode.Alpha3))
            //   {
            //   hacha.SetActive(false);
            //   pico.SetActive(true);
        }
    }
}
// }///////////////////imbento


😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆😆