My Fish Food Won't Fall
by Alexis Ryan Stephens · in Torque Game Builder · 06/03/2010 (11:13 pm) · 6 replies
Ok I admit it, I'm a noob and a spaz and all those fun things. This is my first programming assignment and not a single part of it has worked well for me. I've finally made it to the food falling bit and it won't do it. My teacher even gave me better code and it still won't fall. I have my dynamic fields, I've set the world limits. I've named my class and it still won't fall. The project is due this Sunday and I've been trying to get it to fall since last Sunday. What am I doing wrong?
function FishFood::onLevelLoaded(%this, %scenegraph)
{
%this.startPosition = %this.getPositionY();
%this.setLinearVelocityY(getRandom(%this.minSpeed, %this.maxSpeed));
}
function FishFood::onWorldLimit(%this, %mode, %limit)
{
if(%limit $="bottom")
{
%this.spawn();
}
}
function FishFood::spawn(%this)
{
%this.setPosition(getRandom(-50,50), %this.startPositionY);
%this.setLinearVelocityY(getRandom(%this.minSpeed, %this.maxSpeed));
}
function FishFood::onLevelLoaded(%this, %scenegraph)
{
%this.startPosition = %this.getPositionY();
%this.setLinearVelocityY(getRandom(%this.minSpeed, %this.maxSpeed));
}
function FishFood::onWorldLimit(%this, %mode, %limit)
{
if(%limit $="bottom")
{
%this.spawn();
}
}
function FishFood::spawn(%this)
{
%this.setPosition(getRandom(-50,50), %this.startPositionY);
%this.setLinearVelocityY(getRandom(%this.minSpeed, %this.maxSpeed));
}
#2
%this.setLinearVelocityY(getRandom(%this.minSpeed, %this.maxSpeed));
With this:
%this.setLinearVelocityY(15);
Troubleshooting means stripping away variables until you get down to the bare bones, and then incrementally adding variables back to see where it fails. Welcome to my world!
06/04/2010 (5:28 am)
Assuming you can see the food, but its not falling, try replacing these 2 lines:%this.setLinearVelocityY(getRandom(%this.minSpeed, %this.maxSpeed));
With this:
%this.setLinearVelocityY(15);
Troubleshooting means stripping away variables until you get down to the bare bones, and then incrementally adding variables back to see where it fails. Welcome to my world!
#3
06/04/2010 (5:42 am)
You're also setting this:%this.startPosition = %this.getPositionY();but trying to use this, which is never set:
%this.startPositionYNotice that your missing the "Y" in the first line of code.
#4
06/04/2010 (6:34 am)
Good catch Patrick!
#5
06/04/2010 (6:41 am)
Thanks Kevin... You get that strafe code worked out?
#6
Fangorodrim.zip (13 megs)
I've made a lot of changes in the graphics and interface. Also, your numbers effect appears in the alien sector.
06/04/2010 (8:44 am)
I think so. I'm not sure how effective it is. If you have time, could you test it for me?Fangorodrim.zip (13 megs)
I've made a lot of changes in the graphics and interface. Also, your numbers effect appears in the alien sector.
Torque Owner Matt Clayton
Are you adding your FishFood scene objects in the level builder - if so, check the layer - are they hidden behind other scene objects?