void FixedUpdate() { //ACTUALIZAR EL MOVIMIENTO float horizontal = Input.GetAxis(horizontalAxis); //valor entre -1 y 1 float vertical = Input.GetAxis(verticalAxis); //valor entre -1 y 1 Vector3 direction = new Vector3(horizontal, 0, vertical); theBody.AddForce(direction.normalized * maxSpeed); //ACTUALIZAR LA VELOCIDAD theBody.velocity = new Vector3( Mathf.Clamp(theBody.velocity.x, -maxSpeed, maxSpeed), Mathf.Clamp(theBody.velocity.y, -maxSpeed, maxSpeed), Mathf.Clamp(theBody.velocity.z, -maxSpeed, maxSpeed) ); //ROTACIÓN DE LA NAVE CON RATON if (mouseLook) { Vector3 mousePositionInScreen = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0.0f); Vector3 mousePositionInWorld = Camera.main.ScreenToWorldPoint(mousePositionInScreen); mousePositionInWorld = new Vector3(mousePositionInWorld.x, 0.0f, mousePositionInWorld.z); Vector3 positionToLook = mousePositionInWorld - theTransform.position; theTransform.localRotation = Quaternion.LookRotation(positionToLook.normalized, Vector3.up); } // Checar si la nave puede disparar if (Input.GetButtonDown(fireAxis) && canFire) { foreach (Transform t in weaponTransforms) { AmmoManager.spawnAmmo(t.position, t.rotation); } canFire = false; Invoke("EnableFire", reloadDelay); } }