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