I just started in Unity, so here is what I have:
public class PlayerMovement : MonoBehaviour
{
private Rigidbody2D body;
private void awake()
{
body = GetComponent Rigidbody2D();
}
private void Update()
{
body.velocity = new Vector2(Input.GetAxis("Horizontal"), body.velocity.y);
}
}
↧