imanidukes / Misc-Games

Games created on Unity (Jordan, Imani)
0 stars 0 forks source link

Movement #14

Open imanidukes opened 1 day ago

imanidukes commented 1 day ago

using UnityEngine;

public class PlayerMovement : MonoBehaviour { [SerializeField] private float speed; private Rigidbody2D body; private bool grounded;

private void Awake()
{
    body = GetComponent<Rigidbody2D>();
}

private void Update()
{
    float horizontalInput = Input.GetAxis("Horizontal");
    body.velocity = new Vector2(horizontalInput * speed, body.velocity.y);

    if(Input.GetKey(KeyCode.Space))
        body.velocity = new Vector2(body.velocity.x, speed);

}

private void Jump()
{
    body.velocity = new Vector2(body.velocity.x, speed);

}

private bool isGrounded()
{

    return false;
}

}