Game Development Community

On Collision

by RAHUL THAKUR · in General Discussion · 03/15/2008 (2:20 am) · 2 replies

I working with torque fishing game tutorial & i got stuck in collision function (called as onCollision).

To be more precise the code is like:

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

This code work fine but, from "%scrObj" it is not calling the function "spawn". Its give an error like "object not found" in console when the collision happen.

I am bit confuse, because since on collision it recognize" %dstObj.class" is equal to "PlayerFish" but it not calling the function "spawn" with the object "%scrObj" inside "if" statement. Where as "spawn" function is define in the same class ( FishFood ).


If any one can help me out from this problem.

Thanks in Advance,

#1
03/16/2008 (1:31 am)
First of all, EXACT error messages are always very helpful to those would would seek to help you. Copy/paste or a screenshot is a good idea, here.

Second, the problem is most likely that the incorrect object is being passed to that parameter. Throw some echo's in there and get simID's for the various objects in the mission editor to analyze that problem.

I use Torsion IDE for torquescript, and recommend it to anyone who will listen.
#2
03/16/2008 (5:16 am)
Seconded. Torsion will speed up debugging by lightyears.

In the future, you may also want to post your engine specific questions in the proper forum. (ie: if you're using TGB, post in the private or public TGB forums etc.)