basically I want to make a Zig-zag movement on a 2d top-down and I have a problem when add`(input.getmousebuttondown(0))` it always blinked and not what i want

```
public float frequency = 10f;
public float magnitude = 5f;
public float speed = 10f;
float percentage = 0;

Vector3 pos;
Vector3 axis;

public Rigidbody2D rb2d;

// Start is called before the first frame update
void Start()
{
    pos = transform.position;
    axis = transform.right;
}

// Update is called once per frame
void Update()
{
    Movement();
}

public void Movement()
{
    pos += Vector3.up * Time.deltaTime * speed;
if(Input.GetMouseButtonDown(0)){
transform.position = pos + axis * Mathf.Sin(Time.time * frequency) * magnitude;
}

```

Also, I want the mechanics like that on on picture,
[![I want the mechanics like this](https://i.stack.imgur.com/8tI86.png)](https://i.stack.imgur.com/8tI86.png)

so when i tap the ball will zig-zag but if i not tap the ball just go to right direction like on the pictures,

like this what i mean ![](https://media.giphy.com/media/qwmPXTBezGLAE0k1z8/giphy.gif)