using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class johnsa : MonoBehaviour
{
private Rigidbody2D Rigidbody2D;
private float horizontal;
// Start is called before the first frame update
void Start()
{
Rigidbody2D = GetComponent();
}
// Update is called once per frame
void Update()
{
horizontal = Input.GetAxisRaw("Horizontal");
if (Input.GetKeyDown(KeyCode.W))
{
Jump();
}
}
private void Jump ()
{
Rigidbody2D.AddForce(Vector2.up);
}
private void fixedUpdate()
{
Rigidbody2D.velocity = new Vector2(horizontal, Rigidbody2D.velocity.y);
}
}