I have created a cube in Visual Studio using C++ and I am trying to give it a random direction to move along. From what I have seen online, the equations I'm using for random numbers should be generating a random number between -1 and 1 or more formally (-1, 1). But for some reason, the random numbers being generated are the exact same.
I feel like there is something wrong with the division but I just cannot figure it out. Any help would be appreciated!
// Give the cube a random direction
float x = 2*((float)rand()/(float)(RAND_MAX + 1.0)) - 1;
float y = 2*((float)rand()/(float)(RAND_MAX + 1.0)) - 1;
float z = 2*((float)rand()/(float)(RAND_MAX + 1.0)) - 1;
m_directionVector = XMFLOAT3(x, y, z);