dash and jump almost final version
This commit is contained in:
@@ -5,15 +5,18 @@ public class DropletMovement : MonoBehaviour
|
|||||||
{
|
{
|
||||||
private Rigidbody2D rb;
|
private Rigidbody2D rb;
|
||||||
|
|
||||||
|
// helper variables
|
||||||
|
private bool isGrounded = true;
|
||||||
|
private float facingDirection = 1f;
|
||||||
|
|
||||||
|
// movement
|
||||||
|
private Vector2 movement;
|
||||||
public float jumpingPower = 5f;
|
public float jumpingPower = 5f;
|
||||||
public float moveSpeed = 5f;
|
public float moveSpeed = 5f;
|
||||||
|
|
||||||
private Vector2 movement;
|
// dashing
|
||||||
private bool isGrounded = true;
|
|
||||||
|
|
||||||
private bool canDash = true;
|
private bool canDash = true;
|
||||||
private bool isDashing;
|
private bool isDashing;
|
||||||
|
|
||||||
public float dashingPower = 24f;
|
public float dashingPower = 24f;
|
||||||
public float dashingTime = 0.2f;
|
public float dashingTime = 0.2f;
|
||||||
public float dashingCooldown = 1f;
|
public float dashingCooldown = 1f;
|
||||||
@@ -34,6 +37,9 @@ public class DropletMovement : MonoBehaviour
|
|||||||
|
|
||||||
movement.x = Input.GetAxisRaw("Horizontal");
|
movement.x = Input.GetAxisRaw("Horizontal");
|
||||||
|
|
||||||
|
if (movement.x < 0) facingDirection = -1;
|
||||||
|
if (movement.x > 0) facingDirection = 1;
|
||||||
|
|
||||||
if (isGrounded &&
|
if (isGrounded &&
|
||||||
(Input.GetKeyDown(KeyCode.Space) ||
|
(Input.GetKeyDown(KeyCode.Space) ||
|
||||||
Input.GetKeyDown(KeyCode.UpArrow) ||
|
Input.GetKeyDown(KeyCode.UpArrow) ||
|
||||||
@@ -87,4 +93,14 @@ public class DropletMovement : MonoBehaviour
|
|||||||
|
|
||||||
canDash = true;
|
canDash = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnCollisionEnter2D(Collision2D col)
|
||||||
|
{
|
||||||
|
isGrounded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCollisionExit2D(Collision2D col)
|
||||||
|
{
|
||||||
|
isGrounded = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user