av Mike Ton 9 år siden
331
Mer som dette
return (HasDoubleJumped) ? new Vector2(0, doubleJumpPower) : new Vector2(0, jumpPower);
//???
//ray casting on left and right side
//changes max height based on if double jump is possible or not
RemovedJumpInputCheck(){ ... }
JumpInputCheck(){ ... }
// draws all rays in up and down direction
if(!IsGrounded){ ... }
moveDirection += jumpDirection;
// moveDirection holds final value of movement delta
//apply gravity
else if(IsMaxHeightReached || !IsHoldingJump){ ... }
//else MaxHeight must be reached or no longer holding jump to apply gravity
if (!allowVariableJumpHeight){ ... }
jumpDirection += new Vector2(0, currentGravity);
//if not variable jump, just apply gravity
if (allowVariableJumpHeight) { ... }
if(AtMaxVariableJumpHeight()){ ... }
// check if we're at max height so we can apply gravity
if (bCeiling) { ... }
IsMaxHeightReached = true;
jumpDirection = (jumpDirection.y > 0) ? new Vector2(0, 0) : jumpDirection;
// if hit ceiling, stop all upward movement.
// if airborne, apply gravity to current jump speed then add to movement vector
else if(Input.GetButtonUp("Jump")) { ... }
IsHoldingJump = false;
if(Input.GetButtonDown("Jump")){ ... }
if (!IsHoldingJump && (IsGrounded || (allowDoubleJump && IsDoubleJumping && !HasDoubleJumped)) && !RaycastCollideVertical(Vector3.up)) { ... }
if (allowDoubleJump && !HasDoubleJumped && HasJumpedOnce) { ... }
transform.Translate(moveDirection * Time.deltaTime);
// move via transform component
CalculateMoveDirection();
bool bCeiling = RaycastCollideVertical(Vector2.up);