Game Development Community

Projectile problem

by Mike Daly · in Torque Game Engine Advanced · 12/02/2007 (6:47 pm) · 0 replies

I have a projectile weapon that is (for now) based on the crossbow. Whenever I click the fire button I get an error saying

Register object failed for object (null) of class Projectile.

Here is my Projectile datablock:

datablock ProjectileData(boomProjectile)
{
   projectileShapeName = "~/data/shapes/Boomerang/boomerang.dts";
   directDamage        = 10;
   radiusDamage        = 0;
   damageRadius        = 1;
   //explosion           = pistolExplosion;
   //particleEmitter     = pistolBoltEmitter;

   muzzleVelocity      = 100;
   velInheritFactor    = 1.0; //default was 0.3

   armingDelay         = 0;
   lifetime            = 5000;
   fadeDelay           = 5000;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod		   = 0.00;
   hasLight    = false;
   lightRadius = 1;
   //lightColor  = "0.5 0.5 0.25";

   hasWaterLight     = false;
   //waterLightColor   = "0 0.5 0.5";
};

Also, here's the onFire function:

function boomImage::onFire(%this, %obj, %slot)
{
	echo("THROW");
	//echo(%slot);
	
	%projectile = %this.projectile; //boomProjectile;
	%muzzleVector = %obj.getMuzzleVector(%slot);
	
	//echo("PROJ" SPC %projectile.muzzleVelocity);
	//echo(%obj.getMuzzleVector(%slot));
	
	echo(%obj.getVelocity);
	echo(%projectile.muzzleVelocity);
	echo(%projectile.velInheritFactor);

	%objectVelocity = %obj.getVelocity();
	%muzzleVelocity = VectorAdd(
      VectorScale(%muzzleVector, %projectile.muzzleVelocity),
      VectorScale(%objectVelocity, %projectile.velInheritFactor));
	  
	echo(%this.projectileType);
	  
	/*throws register object failed for object (null) of class projectile when onFire is called-no solution yet*/
	%p = new (%this.projectileType)() {
      dataBlock        = %projectile;
      initialVelocity  = %muzzleVelocity;
      initialPosition  = %obj.getMuzzlePoint(%slot);
      sourceObject     = %obj;
      sourceSlot       = %slot;
      client           = %obj.client;
   };
   
   MissionCleanup.add(%p);
   return %p;
}

It's almost excatly the same as the crossbow, which is working fine. I've tried giving the projectile a name (in place of null) but that has no effect. Any suggestions would be appreciated.
Thanks.