Files
DropToTheRoots/Game/Assets/Scripts/DropletMovement.cs
T

37 lines
892 B
C#

using UnityEngine;
public class DropletMovement : MonoBehaviour
{
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;
[SerializeField] private float dashSpeed;
[SerializeField] private float dashDuration;
private float dashTime;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
if (isGrounded && Input.GetKeyDown(KeyCode.Space))
{
rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpingPower);
}
}
private void FixedUpdate()
{
rb.linearVelocity = new Vector2(movement.x * moveSpeed, rb.linearVelocity.y);
}
}