Fish demo" tutorial problem / question
by Dayton Williams · in Torque Game Builder · 07/26/2006 (9:31 pm) · 1 replies
So I'm trying to be a little creative with my implementation of movement along the y-axis ... I'm having trouble getting the onWorldLimit function to actually trigger when the fish hits the top / bottom limits.
Below's what I've got. As near as I can tell, the "top" and "bottom" cases aren't getting hit at all. The fish just up and goes right off the top/bottom of the screen.
// Tutorial 5
function FishClass::onWorldLimit(%this, %mode, %limit)
{
switch$ (%limit)
{
case "left":
%this.setLinearVelocityX(20);
%this.setFlipX(false);
case "right":
%this.setLinearVelocityX(-20);
%this.setFlipX(true);
%this.setLinearVelocityY(getRandom(-20, 20));
case "top":
%this.setLinearVelocityY(-20);
case "bottom":
%this.setLinearVelocityY(20);
}
}
Below's what I've got. As near as I can tell, the "top" and "bottom" cases aren't getting hit at all. The fish just up and goes right off the top/bottom of the screen.
// Tutorial 5
function FishClass::onWorldLimit(%this, %mode, %limit)
{
switch$ (%limit)
{
case "left":
%this.setLinearVelocityX(20);
%this.setFlipX(false);
case "right":
%this.setLinearVelocityX(-20);
%this.setFlipX(true);
%this.setLinearVelocityY(getRandom(-20, 20));
case "top":
%this.setLinearVelocityY(-20);
case "bottom":
%this.setLinearVelocityY(20);
}
}
Torque 3D Owner Matthew Langley
Torque