void entrada() { float velRel = 0; if (entradaAlternativa != null) { velRel = entradaAlternativa.Horizontal; } if (velRel == 0) { velRel = Input.GetAxis("Horizontal"); } if (velRel > 0) { velRel = 1; } else if (velRel < 0) { velRel = -1; } bool mustFlip = (mirandoALaDerecha && velRel < 0) || (!mirandoALaDerecha && velRel > 0); if (mustFlip) { flip(); } if (Input.GetAxis("disparar1") > 0 || (entradaAlternativa != null && entradaAlternativa.getDisparar(0))) { ataque1.Disparar(); } else if (Input.GetAxis("disparar2") > 0 || (entradaAlternativa != null && entradaAlternativa.getDisparar(1))) { ataque2.Disparar(); } bool jump = Input.GetKeyDown(KeyCode.UpArrow); if ((jump || (entradaAlternativa != null && entradaAlternativa.Jump > 0)) && numeroDeSaltosPosibles > 0) { numeroDeSaltosPosibles--; Saltar(); } Vector3 direccion = Vector3.Cross(upVector, Vector3.forward); Vector3 velTmp = rigidbody2D.velocity; if (isJumping) { velTmp.y = rigidbody2D.velocity.y; } else if (!estaEnElAire()) { velTmp.y = direccion.y * velRel * VelocidadMaxima; } velTmp.x = VelocidadMaxima * direccion.x * velRel; if (isJumping) { velTmp.x /= 2.5f; } rigidbody2D.velocity = velTmp; animacion.SetFloat("velocidad", Mathf.Abs(VelocidadMaxima * velRel)); }