RecastJSPlugin's "getRandomPointAround" is not random

The RNG used to pick the random point uses the same seed every time, so every time I run my game it generates random points in the same sequence every time.

The RNG: https://github.com/BabylonJS/Extensions/blob/658389a5d619d6dbb1b4646df993068268a69e21/recastjs/src/recastjs.cpp#L23

int g_seed = 1337;
inline int fastrand() 
{ 
    g_seed = (214013*g_seed+2531011); 
    return (g_seed>>16)&0x7FFF; 
} 

Is there a way to get it to generate a different sequence each time? Or can we modify the plugin to allow passing in a seed? cc @Cedric

@Cedric will be back soon from the winter break, please, bear with us in the meantime

Yes, I’ll add a method to set the seed.

1 Like
2 Likes