// metodo para detectar colision con el gancho del player y lo engancha void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Gancho")) { hook = other.gameObject.GetComponent <MovGancho>(); Enganche(); } }
//Coge la componente MovGancho del gancho private void OnTriggerEnter2D(Collider2D other) { //cogemos la referencia al gancho if (other.gameObject.CompareTag("Gancho")) { estadoAct = other.gameObject.GetComponent <MovGancho>(); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("QuimicoFuego")) { Destroy(this.gameObject); Destroy(other.gameObject); MovGancho mov = other.GetComponentInParent <MovGancho>(); if (mov != null) { mov.cambiaEstado(HookState.Vuelta); } } }
// metodo para detectar colision con el gancho del player void OnTriggerEnter2D(Collider2D other) { MovGancho hook = other.gameObject.GetComponent <MovGancho>(); if (hook != null) { if (Physics2D.Raycast(transform.position, transform.TransformDirection(Vector2.down), 2, Mask)) // detectar si se esta en contacto con el suelo { colision = true; } else { colision = false; } } }
private void Start() { gancho = transform.GetChild(0).GetComponent <MovGancho>(); rb = GetComponent <Rigidbody2D>(); //Si no tiene Rigidbody if (rb == null) { Debug.LogError("Falta RigidBody"); } dirGancho = Vector2.right; posGanchoInicio = gancho.transform.localPosition; rb.constraints = RigidbodyConstraints2D.FreezeRotation; anim = GetComponent <Animator>(); spr = GetComponent <SpriteRenderer>(); puedeSaltar = false; contactFilter.SetLayerMask(Physics2D.GetLayerCollisionMask(gameObject.layer)); //el filtro detecta las colisiones en la layer del player contactFilter.useLayerMask = true; }
//si colisiona con algun quimico cambiamos a ese estado y lo destruimos. //Ademas hacemos que el gancho vuelva void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("QuimicoFuego")) { estadoEnemigo = EnemyState.Quemado; Destroy(other.gameObject); MovGancho mov = other.GetComponentInParent <MovGancho>(); if (mov != null) { mov.cambiaEstado(HookState.Vuelta); } SoundManager.instance.CallSoundManager("fuego"); } else if (other.gameObject.CompareTag("QuimicoElectrico")) { estadoEnemigo = EnemyState.Paralizado; Destroy(other.gameObject); MovGancho mov = other.GetComponentInParent <MovGancho>(); if (mov != null) { mov.cambiaEstado(HookState.Vuelta); } SoundManager.instance.CallSoundManager("electrico"); } else if (other.gameObject.CompareTag("QuimicoHielo")) { estadoEnemigo = EnemyState.Congelado; Destroy(other.gameObject); MovGancho mov = other.GetComponentInParent <MovGancho>(); if (mov != null) { mov.cambiaEstado(HookState.Vuelta); } SoundManager.instance.CallSoundManager("hielo"); } }
bool ida; //variable para soltar el quimico void Start() { ida = false; estadoAct = null; }
private void Start() { gancho = this.GetComponent <MovGancho>(); }