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?
About the author
#2
That is the code, I don't know whats wrong with it..
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..
Employee Michael Perry
ZombieShortbus