m_Name:
m_EditorClassIdentifier:
flashingTime: 0.3
+ invulnerable: 0
--- !u!114 &243225413
MonoBehaviour:
m_ObjectHideFlags: 0
speed: 36
jumpForce: 50
jumptime: 0.5
+ coyoteTime: 0.1
isGrounded: 0
groundcheck: {fileID: 972365582}
checkRadius: 0.5
m_EditorClassIdentifier:
lastCheckpointPos: {x: 0, y: 0, z: 0}
firstCheckpoint: {fileID: 936765971}
- mouse: {fileID: 214740917}
+ mouse: {fileID: 1649732366}
lastCheeseCount: 0
isCheeseCoinCollected: 0
--- !u!1 &1423339812
public float jumptime;
private bool isJumping;
private float moveInput;
+ public float coyoteTime;
+ private bool jumpAllowed;
+ [HideInInspector]
public bool isGrounded;
public Transform groundcheck;
public float checkRadius;
// Update is called once per frame
void Update()
{
- if (isGrounded == true && Input.GetButtonDown("Jump"))
+ if (!isGrounded)
+ {
+ StartCoroutine(CoyoteTime());
+ }
+ else
+ {
+ jumpAllowed = true;
+ }
+
+ if (jumpAllowed && Input.GetButtonDown("Jump"))
{
isJumping = true;
jumpTimeCounter = jumptime;
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
}
- if (Input.GetButton("Jump") && isJumping == true)
+ if (Input.GetButton("Jump") && isJumping)
{
if (jumpTimeCounter > 0)
{
return true;
}
- return false;
+ return false;
}
void FixedUpdate()
}
}
+ IEnumerator CoyoteTime()
+ {
+ yield return new WaitForSeconds(coyoteTime);
+ jumpAllowed = false;
+ }
+
void ResetShoot()
{
isShooting = false;