void OnCollisionEnter2D(Collision2D otro) { string capa = LayerMask.LayerToName(otro.gameObject.layer).ToLower(); string etiqueta = otro.transform.gameObject.tag.ToLower(); if (checks.IsWall() && !pillado && !girando && !sentado) { StartCoroutine(PararYGirar()); } if (otro.gameObject.tag.ToLower().Contains("player")) { } }
void OnCollisionStay2D(Collision2D other) { if (other.transform.tag == "Player" && Checks.IsWall()) { if (ctrlPlayer.getPushing() == false) { foreach (Image a in imagesOfCanvas) { if (a.name.ToLower().Contains("button")) { a.enabled = true; } else { a.enabled = false; } } thisCanvas.enabled = true; thisRigid.isKinematic = true; } else { if (playerTransform.position.x < this.transform.position.x) { foreach (Image a in imagesOfCanvas) { if (a.name.ToLower().Contains("right")) { a.enabled = true; } else { a.enabled = false; } } } else { foreach (Image a in imagesOfCanvas) { if (a.name.ToLower().Contains("left")) { a.enabled = true; } else { a.enabled = false; } } } thisRigid.isKinematic = false; if (Mathf.Abs(thisRigid.velocity.x) > 0.3f) { thisCanvas.enabled = false; } else { thisCanvas.enabled = true; } } } }
void Update() { // SI... Pulsamos la tecla de salto (Espacio) if (Input.GetKeyDown(KeyCode.Space)) { // Y ..SI .. estamos tocando suelo ('isGround') // Igualamos variable ('starJump') a true. (Comenzamos a saltar). // Igualamos a 0 la variable que controla el tiempo que pulsamos el salto (timePressing). if (Checks.IsGround()) { startJump = true; timePressing = 0f; } // Sino.. Si se está agarrando ('isGrip'). // Igualamos variable rebote ('isBounce') a true. // Llamamos a la corutina Bouncing. // Igualamos el tiempo que pulsamos el salto ('timePressing'), al máximo tiempo permitido ('maxTimeJump'). else if (isGrip) { isBounce = true; StartCoroutine(Bouncing(horizontalDirection)); timePressing = maxTimeJump; } // Sino.. es que ya estamos en el aire // Igualamos la variable ('starJump') a false. // Igualamos el tiempo que pulsamos el salto ('timePressing'), al máximo tiempo permitido ('maxTimeJump'). else { startJump = false; timePressing = maxTimeJump; } } // SI... Mantenemos pulsada la tecla salto (Espacio) y el tiempo pulsada (timePressing) es menor que el tiempo máximo pulsando (maxTimeJump) if (Input.GetKey(KeyCode.Space) && timePressing < maxTimeJump) { timePressing += Time.deltaTime; } // Si... Soltamos la tecla salto (Espacio)....Reiniciamos a 0 la variable 'timePressing' if (Input.GetKeyUp(KeyCode.Space)) { timePressing = maxTimeJump; } if (Input.GetKeyDown(KeyCode.DownArrow)) { thisAnimator.SetInteger(hashAgachado, 1); } if (Input.GetKey(KeyCode.DownArrow)) { thisAnimator.SetInteger(hashAgachado, 2); } if (Input.GetKeyUp(KeyCode.DownArrow)) { if (thisAnimator.GetInteger(hashAgachado) != 3) { thisAnimator.SetInteger(hashAgachado, 3); } else { thisAnimator.SetInteger(hashAgachado, 1); } } if (Input.GetKey(KeyCode.E) && Checks.IsWall()) { //pushing = true; } if (Input.GetKeyUp(KeyCode.E) && Checks.IsWall()) { //pushing = false; } }