basic MEL help please
Hi there.
I want to create the effect of sheet lightning, by randomising the intensity of a point light. I can get this to happen, but i need it so that i can vary the time between flashes, like i need an avg random 30 frames between changes. i came up with this, having not much programming or MEL experience, //setup values int $mycount; $mycount = rand(20,30); int $i; //loop for 380 frames for ($i=1; $i <380; $i++) { //check random value against frame value if (frame == $mycount) { //change light intensity pointLightShape1.intensity = rand(0,1); //increase random value to progress $mycount += $mycount; } } and now I'm stuck. can anyone point out where i went wrong? it only changes the intensity once. and then not even everytime i play it through. or perhaps a less round about way of doing it? thanks!! Adam. |
wait.. let me first try to figure out what youre trying to do..... as the animation plays, you want random flashes every 30 frames?
-Emo |
a random vaule for the illumination yes.
and approximately every 30 frames. I wanted to randomise the time between flashes. so approx 30 frames, say a random interval between 10 and 40. |
this would be easier as an expression:
right click the intensity in the channel box and add this: if(frame % 30 == 0) { pointLightShape1.intensity = rand(0,5); } What you are doing is using the modulus function (%) to check if the frame divides equally by thirty and then setting the intensity by expression. Simple :ninja: Alan |
thanks Alan!
i was at a bit of a loss how to do the time delay properly. that would only make it exactly 30 frames though? i want it to be more random than that. like lightning a couple of quick flashes, a pause, flash, pause, some more quick, or whatever. |
well if you want it that specific then you may have to key it. You can use a random number instead of the frame number:
int $frameChange = rand(10, 40); if(frame % $frameChange == 0) { pointLightShape1.intensity = rand(0,5); } Alan |
no no, not specific, random is what i want.
that random function should work a treat, thanks for that Alan. I really appreciate the effort you make helping out me and other newbies. this is what i ended up with, if anyone was interested in how it ended up working. //setup values int $mynumber; int $i; //loop for 380 frames for ($i=1; $i <380; $i++) { $mynumber = rand(50,80); if (frame % $mynumber == 0) { pointLightShape1.intensity = rand(0,1); //increase random value to progress $mynumber += $mynumber; } } |
All times are GMT. The time now is 05:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018