Noticias

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

Problemas con script de puerta y llave

Iniciado por Miguel Torrealba, Septiembre 02, 2015, 07:41:54 AM

Tema anterior - Siguiente tema
Septiembre 02, 2015, 07:41:54 AM Ultima modificación: Junio 02, 2016, 12:05:59 AM por pioj
He estado creando en estos dias un script para una puerta y una llave, pero tengo un problema que el script no reconoce cual es la llave correcta , asi que cuando agarro una llave se habren todas y no identifica cual es cual, son 2 script uno de la llave y otro de la puerta.
 
 
 
Codigo LLave
 

using UnityEngine;
using System.Collections;
public class LlavesScript : MonoBehaviour {
    public AudioClip SonidoRecogerLlave;
    
    // Use this for initialization
    void Start () {
    }
    
    // Update is called once per frame
    void OnTriggerStay (Collider other) {
        if (other.tag == "Player") 
        {
                Debug.Log("Click para recoger");
                {
                        if (Input.GetMouseButton())
                        {
                            NotificationCenter.DefaultCenter().PostNotification(this,"llaveRecogida");
                            AudioSource.PlayClipAtPoint(SonidoRecogerLlave,transform.position);
                            Debug.Log ("Tienes la llave");
                        }
                }
        }
    }
}

 
Codigo puerta
 

using UnityEngine;
using System.Collections;
public class PuertaScript : MonoBehaviour {
    private float AngleY = 90.0f;    
    
    private float targetValue = 0.0f;
    private float currentValue = 0.0f;
    private float easing = 0.05f;
    public bool Abierta = false;
    public bool tieneLlave = false;
    public AudioClip sonidoPuertaCerrada;
    public AudioClip sonidoPuertaAbierta;
    public GameObject Target;  //bisagra
    public GameObject llave;
    public string nombre;
    void Start ()
    {
        NotificationCenter.DefaultCenter().AddObserver(this,"llaveRecogida");
    }
    
    void  Update (){
        
        
        currentValue = currentValue + (targetValue - currentValue) * easing;
        Target.transform.rotation = Quaternion.identity; // set rotation to zero
        Target.transform.Rotate(, currentValue, ); // apply full Rotation
        if (Input.GetMouseButton ()) {
                        Debug.Log ("click");
                }
    
        if (targetValue == AngleY && currentValue == ) {tieneLlave =false;}
        
    }
    void OnTriggerStay (Collider other){
    
                        if (Abierta == false) {
                                if (other.gameObject.tag == "Player" && tieneLlave) {
                                        if (Input.GetMouseButtonDown ()) {
                                                targetValue = AngleY;
                                                currentValue = ;
                                                Abierta = true;
                                                audio.clip = sonidoPuertaAbierta;
                                                audio.loop = false;
                                                audio.Play (); 
                                
                                        }
                                }
                        }
                
       if (other.gameObject.tag == "Player" && !tieneLlave) {
            if (Input.GetMouseButtonDown()){
                        Debug.Log ("ESTA CERRADO");
                        audio.clip = sonidoPuertaCerrada;
                        audio.loop = false;
                        audio.Play ();     
                }
            if (Abierta){
                targetValue = ;
                currentValue = ;
                }
        }
        }
    void llaveRecogida (Notification notificacion){
    
                if (llave.name == "Llave1") {
                        tieneLlave = true;
        }  
        }
}

 
ya intente todo lo que se Ayuda por favor!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

No dupliques hilos, con preguntarlo en 1 solo sitio vale

Etiquetas: