public class PlayerController : MonoBehaviour
{
public Rigidbody2D rb;
public float speed = 10f;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKey("W"))
{
rb.AddForce(0, speed * Time.deltaTime, 0);
}
if (Input.GetKey("S"))
{
rb.AddForce(0, -speed * Time.deltaTime, 0);
}
}
}