rigidbody2D.velocity
private void Update()
{
rigidbody2D.velocity = new Vector2(speed, rigidbody2D.velocity.y);
if (leftPos != leftBttn.transform.position.y)
{
//rigidbody2D.velocity = new Vector2(speed, rigidbody2D.velocity.y);
speed = -5f;
}
else if (rightPos != rightBttn.transform.position.y)
{
speed = 5f;
}
else
{
speed = 0f;
}
rigidbody2D.velocity = new Vector2(speed, rigidbody2D.velocity.y);
}