Game Development Community

Collisions issues with Fish game

by Matthew Shapiro · in Torque Game Builder · 09/03/2007 (4:26 am) · 1 replies

Hi guys, I"m getting a wierd problem when going through the Fish Game demo. I'm up to the point where I add the fish food and adding collision to the food. I added the collision function just like it was shown on the tutorial and played the level and noticed nothing happened when my PlayerFish collided with the bubble. Finally I added an echo statement in, so my function looked like this (After not being able to fix this issue I tried adding the fish from the next step):

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

So now whenever my PlayerFish collides with the bubble, it spams the console with "N". I went back to my PlayerFish, pulled down the scripting tag and confirmed that ti's correctly set to use the PlayerFish class (which seems pretty obvious since the fish responds movement controls). So then I went to the next step and added the NPC fish. I waited till it collided with the pellet and lo and behold, it's doing the same thing on collision (spamming "N")

Finally I copied the function and made it a part of the PlayerFish class, and collided my PlayerFish with the NPC Fish. The function is this:

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

This makes it print out "N" then "PlayerFish."

What am I doing wrong that is causing the dstObj.Class to always be equal to "N" ?

#1
09/18/2007 (9:04 pm)
I'm pretty sure that onCollision looks more like: onCollision(%srcObject, %dstObject, %srcRef, %dstRef, %time, %normal, %contacts, %points).