Game Development Community

Fish Game onCollision question

by Jeff Williams · in Torque Game Builder · 09/18/2008 (12:38 pm) · 3 replies

In working through the Fish Game Demo I have come across some issues with getting the collision to work properly. I have tried several things but none seem to work.

Here is my onCollision function:

function FishFood::onCollision(%scrObject, %dstObject, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
echo ("===== In the FishFood::onCollision function =====");
echo ("===== The %srcObject.class object is " @ %srcObject.class);
echo ("===== The %dstObject.class object is " @ %dstObject.class);
echo ("===== The %contactCount object is " @ %contactCount);
echo ("===== The %contacts object is " @ %contacts);
echo ("===== End of echo statements. =====");

if(%dstObject.class $= "PlayerFish")
{
%srcObject.spawn();
}
}


Obviously I have put the echo statements in there as a means of debugging what the function is doing.

Here is the output of the echo statements:

game/gameScripts/fishfood.cs (32): Unable to find object: '' attempting to call function 'spawn'
===== In the FishFood::onCollision function =====
===== The %srcObject.class object is L

#1
09/18/2008 (12:42 pm)
Looks like a typo. The "r" and the "c".

In your parameter list you use: %scrObject
In your if statement you use: %srcObject

Try this:
if(%dstObject.class $= "PlayerFish")
{
%scrObject.spawn();
}
}

Word? ...word.
#2
09/18/2008 (12:50 pm)
Boy do I feel STUPID!!!!!

I can't tell you how long I have looked at that and was convinced that everything was ok.

Fixing the typo fixed the problem. Thanks!
#3
09/18/2008 (12:52 pm)
Easy kill, my pleasure.