Trouble with random bubbles
by David Wade · in Torque Game Builder · 02/17/2010 (11:47 pm) · 5 replies
I've been going through the tutorials and right now I'm working on the fishgame tutorial and I'm unable to figure why my random function isn't working. Do I need to seed the random function first? I followed the code exactly and the bubble (fish food) drops in the exact spot that I placed above the game scene. Thanks.
About the author
#2
function FishFood::spawn(%this)
{
%this.setPosition(getRandom(-50, 50), %this.startPositionY;
%this.setLinearVelocityY(getRandom(%this.minSpeed, %this.maxSpeed));
}
Of course this isn't all of the fish food file, but this is the most relevant to the random spawning.
I don't think I can post the whole console log here. I can post it to pastebin and leave the link here: http://pastebin.com/madc859
Thanks for your time.
02/18/2010 (8:12 pm)
I'm not sure what you mean by relevant scripts but here is what I think you mean:function FishFood::spawn(%this)
{
%this.setPosition(getRandom(-50, 50), %this.startPositionY;
%this.setLinearVelocityY(getRandom(%this.minSpeed, %this.maxSpeed));
}
Of course this isn't all of the fish food file, but this is the most relevant to the random spawning.
I don't think I can post the whole console log here. I can post it to pastebin and leave the link here: http://pastebin.com/madc859
Thanks for your time.
#3
02/21/2010 (8:34 am)
I had a similar problem. It turned out I just hadn't saved the fish food script file after adding the random function.
#4
02/23/2010 (7:51 pm)
Why would it matter the order you saved the script if they are both in the file?
#5
From looking at your posted log file, I noticed that you have a few compile errors. You might want to fix those and see what happens.
steve
02/25/2010 (12:20 pm)
You shouldn't need to set the random seed, because the common script code should already be doing so. If you feel you need to do that, call "setRandomSeed" with no parameters.From looking at your posted log file, I noticed that you have a few compile errors. You might want to fix those and see what happens.
steve
Torque 3D Owner Matthew Langley
Torque
1) The relevant scripts (you can use the markup tags here to keep formatting)
2) Try running your game, see it not working, close it, then go to your project's directory and find the console.log file and post that here .You can see this console information by pressing the "~" (tilde key) while the game is running, any errors will come up in red.