Game Development Community

T3D 1.1 Beta 3 - setCollisionTimeout is broken in the engine

by Ian Backlund · in Torque 3D Professional · 12/10/2010 (4:04 am) · 1 replies

Build: 1.1 Beta 3 only

Platform: any

Issues:
The "Item::setCollisionTimeout()" script definition has a bug that prevents it from working.

Steps to Repeat:
Try using it with health or something. I was throwing a "glass" item and it kept damaging the throwing character because the script call to setCollisionTimeout() kept failing.

Suggested Fix:
I looked at the Item.cpp engine code and there is a bug. I will post the corrected code below:

DefineEngineMethod( Item, setCollisionTimeout, bool, (int ignoreColObj),(NULL), "@brief Temporarily disable collisions against a specific ShapeBase object.nn"
   "@param objectID ShapeBase object ID to disable collisions against.n"
   "@return Returns true if the ShapeBase object requested could be found, false if it could not.n"
   "@tsexamplen"
	   "// Set the ShapeBase Object ID to disable collisions againstn"
	   "%ignoreColObj = %player.getID();nn"
	   "// Inform this Item object to ignore collisions temproarily against the %ignoreColObj.n"
	   "%item.setCollisionTimeout(%ignoreColObj);nn"
   "@endtsexamplenn"
   )
{
   ShapeBase* source = NULL;
   if (Sim::findObject(ignoreColObj,source)) {//IB: BugFix:  if (Sim::findObject(ignoreColObj),source) {
      object->setCollisionTimeout(source);
      return true;
   }
   return false;
}