Game Development Community

My Fish Game - Collision Problem

by Sam.E · in Torque Game Builder · 09/25/2008 (7:14 am) · 2 replies

Hey, while I am doing the My Fish Game tutorial, I get up to the bit where you have to do the collision for the fish and the bubble, but after I do the collision for both of them the bubble doesn't dissappear and doesnt even respawn?? I wrote the script for it out first but I didn't know what happened so I copied the script from the tutorial and that doesnt work ?? What is wrong?

#1
09/25/2008 (9:17 am)
Houssen, could you post the EXACT code you are currently using? Also, have you seen any warnings, error, or other notifications in the console log?
#2
09/25/2008 (3:07 pm)
No errors and this is the exact fish food code...

function FishFood::onLevelLoaded(%this, %scenegraph)
{
   %this.startPosition = %this.getPosition();
   %this.setLinearVelocityY(getRandom(%this.minSpeed, %this.maxSpeed));
}

function FishFood::onWorldLimit(%this, %mode, %limit)
{
   if(%limit $= "bottom")
   {
      %this.spawn();
   }
}


function FishFood::spawn(%this)
{
   %this.setPosition(%this.startPosition);
   %this.setLinearVelocityY(getRandom(%this.minSpeed, %this.maxSpeed));
}

function FishFood::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time, %normal,%contactCount, %contacts)
{
if(%dstObj.class $= "PlayerFish")
{
%srcObj.spawn();
}
}

That is the code, I don't know whats wrong with it..