Was wondering how would I make the movement constant? If put “newVelocity.x = maxSpeed;” below the if() statement it moves to the right until it hits an object which is what I want. If I put it in the if() statement it only plays once. Any idea how to make it move until it hits something while being activated by a button press?
public float jump = 2;
public float speed = 1;
[SerializeField]
Rigidbody2D rb;
void FixedUpdate()
{
var newVelocity = rb.velocity;
if (Input.GetMouseButtonUp(0))
newVelocity.y = jump;
newVelocity.x = speed;
rb.velocity = newVelocity;
}