void Movement() { newTrans.transform.position = mainCam.transform.position; newTrans.transform.rotation = mainCam.transform.rotation; newTrans.transform.eulerAngles = new Vector3(0, newTrans.transform.rotation.eulerAngles.y, 0); float fall = rb.velocity.y; if (control.GetBtnPressed(1)) { fall += jump; } rb.velocity = newTrans.transform.TransformDirection(control.MoveInput) * speed; rb.velocity = new Vector3(rb.velocity.x, fall, rb.velocity.z); if (control.MoveInput != Vector3.zero) { Vector3 tempVel = rb.velocity; tempVel.y = 0; //Use FaceTowardsMovement FaceTowardsDirection(tempVel); } if (control.GetBtnHeld(2)) { rb.velocity = rb.velocity / 2; } anim.SetBool("Slowed", control.GetBtnHeld(2)); anim.SetBool("Woo", control.GetBtnPressed(3)); //FixStuckWall(); anim.SetBool("Moving", control.MoveInput.magnitude > 0.1); //isGrounded = false; previousVel = rb.velocity; }
void Jump() { if (isGrounded) { availableJumps = totalJumps; if (control.GetBtnPressed(4)) { input.y += jumpSpeed; availableJumps -= 1; isGrounded = false; } } else { if (control.GetBtnPressed(4) && availableJumps > 0) { input.y = jumpSpeed; availableJumps -= 1; } if (rb.velocity.y > 0 && control.GetBtnHeld(4)) { currentGravity /= 2; } } }