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
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
Torque Owner RollerJesus
Dream. Build. Repeat.
In your parameter list you use: %scrObject
In your if statement you use: %srcObject
Try this:
if(%dstObject.class $= "PlayerFish") { %scrObject.spawn(); } }Word? ...word.