Hi, I've been working on a rain resource but unfortunately it seems to be slowing down the game massively. I was going to put the resource in the user contributions, but there's not much point if it's going to slow down frame rate... My method: I've created a largish .mdl file full of raindrops. This is then cycled down and rotated around the camera to give the illusion that there is rain everywhere (took a looong time to remember my sin and cos for that one), whilst playing a looping rain sound. The rain.mdl is 316kb - would it be the continual movement of this that is causing the slow down?
This is the code:
var x;
var y;
var hyp;
sound rainsnd=<rain.wav>;
action rain
{
//initialisation:
my.passable=on;
my.transparent=on;
play_loop(rainsnd,100);
rainfall.x=0;
rainfall.y=0;
rainfall.z = -15; //speed of rainfall...
create(<rain.mdl>,nullvector,rain_above); //this is only needed if the player can look directly up - and can slow things
hyp=my.max_x*2.5; // can change this ratio, or even just replace with an arbitrary number...
my.z=camera.z-(my.min_z/1.5); //cut this line if stationary (not to follow player)
//main loop:
while(1)
{
my.roll=10; //change to alter slant of rain
my.tilt=0; //change to alter slant of rain
x=cos(camera.pan)*hyp;
y=sin(camera.pan)*hyp;
my.x=camera.x+x;
my.y=camera.y+y;
move(my,rainfall,nullvector);
//cycle position of rain:
if (my.z+(my.max_z/1.5)<camera.z)
{my.z=camera.z-(my.min_z/1.5);}
wait(1);
}
}
Perhaps there is a better way to create rain? Like with particles? If anyone's got any ideas, I'd be really grateful...
Cheers,
Keith
P.S. "Expert"!!??? 75 posts of dumb questions does not an Expert make...