Spawning projectiles
by Daniel Buckmaster · in Torque Game Engine · 12/24/2007 (12:39 am) · 0 replies
This is probably a stupid question, so thank you for reading. I'm trying to spawn projectiles the way it's done in crossbow.cs. My datablocks are as follows:
Functions:
Is the fault mine?
datablock ProjectileData(LasShotData)
{
shapeFile = "~/data/shapes/crossbow/projectile.dts";
muzzleVelocity = 1;
explosion = CrossbowDebrisExplosion;
};
datablock RangedWeaponData(LasgunData : WeaponPhysicsBase)
{
shapeFile = "~/data/shapes/Imperial/weapons/lasgun/lasgun.dts";
projectile = LasShotData;
};CrossbowDebrisExplosion is copied straight from crossbow.cs. Don't be scared off by RangedWeapon. It behaves pretty much like a RigidShape, but I've added some methods (you'll see them below). They all work as they should.Functions:
function LasgunData::onFire(%this,%obj)
{
%proj = %this.projectile;
%p = new Projectile() {
dataBlock = %proj;
initialVelocity = %obj.getMuzzleVector();
initialPosition = %obj.getMuzzlePoint();
sourceObject = %obj;
sourceSlot = 0;
};
MissionCleanup.add(%p);
echo("Projectile created:");
echo(%proj);
echo(%p);
echo(%obj.getMuzzlePoint());
echo(%obj.getMuzzleVector());
echo(%obj.getMuzzleTransform());
echo(%p.getTransform());
}All the echoed values are correct, but %p.getTransform() returns "0 0 0 1 0 0 0". When I set the camera there and fire again, I can see the projectile being created (in the editor), and immediately disappearing, without even an explosion.Is the fault mine?
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!