trying to figure out how to jump
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"version": "1.0",
|
||||||
|
"components": [
|
||||||
|
"Microsoft.VisualStudio.Workload.ManagedGame"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -2,11 +2,26 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class DropletMovement : MonoBehaviour
|
public class DropletMovement : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
<<<<<<< Updated upstream
|
||||||
|
|
||||||
public float moveSpeed = 5f;
|
public float moveSpeed = 5f;
|
||||||
|
|
||||||
private Rigidbody2D rb;
|
private Rigidbody2D rb;
|
||||||
private Vector2 movement;
|
private Vector2 movement;
|
||||||
|
=======
|
||||||
|
private Rigidbody2D rb;
|
||||||
|
public float moveSpeed = 5f;
|
||||||
|
public float jumpingPower = 5f;
|
||||||
|
private Vector2 movement;
|
||||||
|
private Animator playerAnim; //for animation
|
||||||
|
private float xInput;
|
||||||
|
|
||||||
|
//helper variables
|
||||||
|
private bool isGrounded = true;
|
||||||
|
[SerializeField] private float dashSpeed;
|
||||||
|
[SerializeField] private float dashDuration;
|
||||||
|
private float dashTime;
|
||||||
|
>>>>>>> Stashed changes
|
||||||
|
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
void Start()
|
void Start()
|
||||||
@@ -19,10 +34,15 @@ public class DropletMovement : MonoBehaviour
|
|||||||
{
|
{
|
||||||
movement.x = Input.GetAxisRaw("Horizontal");
|
movement.x = Input.GetAxisRaw("Horizontal");
|
||||||
movement.y = Input.GetAxisRaw("Vertical");
|
movement.y = Input.GetAxisRaw("Vertical");
|
||||||
|
if (isGrounded && Input.GetKeyDown(KeyCode.Space))
|
||||||
|
{
|
||||||
|
rb.AddForce(Vector2.up * jumpingPower, ForceMode2D.Impulse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
{
|
{
|
||||||
rb.linearVelocity = movement.normalized * moveSpeed;
|
rb.linearVelocity = movement.normalized * moveSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user