Noticias

¡RECUERDA QUE SI ERES UN NUEVO USUARIO, DEBES PRESENTARTE PARA PODER PUBLICAR MENSAJES! | TENEMOS CANAL OFICIAL DE TELEGRAM: t.me/unity3dspain

Quiero cambiar la forma de mi script a algo mas general

Iniciado por kalm97, Julio 21, 2015, 08:32:57 PM

Tema anterior - Siguiente tema
Tengo esta script con animaciones para una puerta deslizable  pero lo quiero cambiar a una script general para no hacer muchas animaciones y q crasheen el juego, en vez de una animacion quisiera que e #pragma strictprivate var guiShow : boolean = false;var isOpen : boolean = false;
var door : GameObject;
var rayLength = 10;function Update()
{    var hit : RaycastHit;
    var fwd = transform.TransformDirection(Vector3.forward);
    
    if(Physics.Raycast(transform.position, fwd, hit, rayLength))
    {
        if(hit.collider.gameObject.tag == "Door")
        {
            guiShow = true;
            if(Input.GetKeyDown("e") && isOpen == false)
            {
                door.animation.Play("Door1");
                isOpen = true;
                guiShow = false;
            }
            
            else if(Input.GetKeyDown("e") && isOpen == true)
            {
                door.animation.Play("Door2");
                isOpen = false;
                guiShow = false;
            }
        }
    }
    
    else
    {
        guiShow = false;
    }
}function OnGUI()
{
    if(guiShow == true && isOpen == false)
    {
        GUI.Box(Rect(Screen.width / 2, Screen.height / 2, 100, 25), "E");
    }
    if(guiShow == true && isOpen == true)
    {
        GUI.Box(Rect(Screen.width / 2, Screen.height / 2, 100, 25), "E");
  }
} Ya este script ya lo subi con la misma intencion pero no comprendo lo q me quieren desir no soy bueno asiendo codigos...


@kalm97 , hubiera sido más preferible que continuaras tu duda en el anterior Topic, ya que está relacioanda con el mismo asunto de la puerta deslizable... 

A un script general? Y si es una puerta deslizable, porque directamente no lo haces con transform.Traslate?

Etiquetas: