Files
DropToTheRoots/Game/Assets/Scripts/DropletMovement.cs
T
2026-06-06 01:03:39 +02:00

39 lines
887 B
C#

using UnityEngine;
public class DropletMovement : MonoBehaviour
{
private Rigidbody2D rb;
<<<<<<< HEAD
=======
public float moveSpeed = 5f;
public float jumpingPower = 5f;
private Vector2 movement;
private Animator playerAnim; //for animation
private float xInput;
>>>>>>> 3a4d5de (current correct code inshallah)
public float moveSpeed = 5f;
public float jumpingPower = 5f;
private Vector2 movement;
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);
}
}