Game Development Community

Callbacks aren't called

by Robert Norris · in Torque Game Engine · 07/28/2005 (2:20 am) · 2 replies

Hi,

i've downloaded the laser resource and followed all instructions to include it into my project.

When i start my project mission, my player object appears with the mounted laser weapon, but when i click the left mousebutton, the onFire Method of my laserImage isn't called. For testing i've written a normal laserImage::onTrigger(...) method, but it's also not called when i do a left-click.
My player object also has a onTrigger-Method and this one is called.

Any suggestion why the callback methods of my laserImage aren't called?
I think, that the few given informations can't help to get a solution , but i will give more information on concrete questions, because i don't know which informations are necessary here.

perhaps this is important: The laser resource is based on starter.fps, but my project is based on tutorial.base. I've tried out many things, but nothing works. Perhaps someone could help me?

#1
07/28/2005 (11:03 am)
Are you mounting a laserImage to the player?
#2
07/29/2005 (12:19 am)
I've derived new classes Droid and DroidData from Vehicle and VehicleData.

In droid.cs i do this
function DroidData::onAdd(%this,%obj){
	echo("DroidData::onAdd()");
   %obj.mountImage(LaserImageRight, 0);
	%obj.setInventory(LaserAmmo, LaserAmmo.maxInventory);
	%obj.setInventory(LaserWeapon, 1);
}

I always wonder why it must be DroidData::onAdd() instead of Droid::onAdd, but Droid::onAdd isn't called. Could this be a part of the problem? If it's helpful i can post the whole Droid class and other code snippets here.

UPDATE:
It seems that the LaserImage state is always set to noAmmo. When i comment out all NoAmmo-sequneces, the LaserImage::onFire Method is called, but i get the following error in the console:
"Projectile::onAdd(): mSourceObjectId is invalid"

SECOND UPDATE:
i've debugged Projectile::onAdd(). mSourceObjectId has the value 0. This must be an initial value, because mSourceObjectId is never set to another value. Perhaps there are other positions where mSourceObjectId is modified, but i detected two entries. One in Projectile::processTick() und another in Projectile::unpackUpdate(). Both entries are never reached.

THIRD UPDATE:
OK, i've found it. The error was in the LaserImageRight::onFire() method.
sourceObject was set to an undefined variable instead to the %obj parameter. Now it works.