Hello.
My aim now is to use Random for choosing random Vector3 value, or rather Vector3.up\down\left\right.
Example:
if(timeleft < 0)
{
transform.Rotate(Vector3.left * Time.deltaTime * 30); // here should be random value from left, right, up, down
if(timeleft < -5)
{
timeleft = 5f;
}
}
If I somehow can use Random.Range for playing random sound, I dont mind how it works with Vector3, please, help
Random.Range simply returns a random number between the passed min and max parameters. Interestingly if you’re passing floats, the max parameter is inclusive, but if you’re passing integers the max parameter is exclusive.
Since you’re using Vector3 shorthands you could try something like this:
int randomPick = Random.Range(0,4); //returns randomly 0,1,2,3
switch(randomPick){
case 0:
transform.Rotate(Vector3.left * Time.deltaTime * 30);
break;
case 1:
transform.Rotate(Vector3.right* Time.deltaTime * 30);
break;
case 2:
transform.Rotate(Vector3.up* Time.deltaTime * 30);
break;
case 3:
transform.Rotate(Vector3.right* Time.deltaTime * 30);
break;
default: break;
}