moving objects

Hi guys
I’v been trying to create an array of vector 2 with random values that supposed to move a cube in random directions.
here’s what I have so far.

int arrLen = 300;
private Vector2[ ] vArr;
public Rigidbody rb2d;

// Use this for initialization
void Start () {
vArr = new Vector2[arrLen];
this.rb2d = gameObject.AddComponent();
for (int i = 0; i < vArr.Length; i++){
vArr = new Vector2(Random.Range(-2, 3), Random.Range(-2, 3));
}
}

// Update is called once per frame
void Update () {
if (Time.frameCount < arrLen)
{
this.rb2d.velocity = vArr[Time.frameCount];
}

}
it kinda works but its still not what I want, and I’m new to unity so I’m still trying to figure out stuff

What is it doing?

What do you want?

right now its moving but not smoothly, it shakes while moving and every time I press play the cube moves more or less the same way
this video can be a reference to how I want the cube to move(generally speaking)

https://www.youtube.com/watch?v=bGz7mv2vD6g

at 18:30

The way you’ve programmed it implies that you want it to move a bunch of random directions, but then continue moving in the final direction when the array list runs out?

I think you’ll probably be able to improve the visual if you use a coroutine loop instead of Update and wait a bit between changing directions.