sábado, 17 de septiembre de 2022

Ejemplo muy util de true y false con c# de unity, multiples posibilidades para desarrollar juegos;

 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);


        }
    }
}

 

 

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

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

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

public class pruebamultipletexto : MonoBehaviour
{

    public GameObject texto;
    public GameObject texto2;
    public GameObject texto3;
    public GameObject texto4;
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            texto.SetActive(true);
            texto2.SetActive(true);
            texto3.SetActive(true);
            texto4.SetActive(true);
        }
    }
    private void OnTriggerExit(Collider other)
    {
        if (other.tag == "Player")
        {
            texto.SetActive(false);
            texto2.SetActive(false);
            texto3.SetActive(false);
            texto4.SetActive(false);
        }
    }

}

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

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


Cuando el player pasa por un trigger activado aparece un gameobject o un texto, cuando sale el gameobject desaparece, muy util para poner textos o enemigos o abrir puertas.....(en contruccion seguire explicandolo............en breve.......17-9-22.....aqui el ejemplo debajo de estas lineas....

con estas simples scripts e puesto enemigos, e accionado una puerta, e echo cambios de camaras, y seguro hay muchisimas mas posibilidares.......

 




https://tozudo415.itch.io/demo-4-western-gay