Game Development Community

Shoot

by Daniel Buckmaster · in Torque Game Engine · 02/27/2007 (9:38 am) · 0 replies

I've run into an impasse with my current project. I'm working on a weapon system of my own, not based on the item/image system. However, there are certain onsole methods that are only avalable to weapon images that I really need - like getMuzzleVector. Those things don't seem to work on my StaticShape-based weapon objects.
What I'm trying to do is create and fire a projectile, based on the way it's done in the CodeSampler weapon tutorial.
Something along the lines of:
function RangedWeapon::Fire(%this,%obj)
{
	%pdb = %this.projectile; //Projectile datablock

	%muzzleVector   = %obj.getMuzzleVector(0);
	%objectVelocity = %obj.getVelocity();

	%muzzleVelocity = VectorAdd( VectorScale(%muzzleVector, %pdb.muzzleVelocity),
	                             VectorScale(%objectVelocity, %pdb.velInheritFactor) );

	// Create a new rocket projectile object...
	%p = new (%this.projectileType)()
	{
		dataBlock       = %pdb;
		initialVelocity = %muzzleVelocity;
		initialPosition = %obj.getMuzzlePoint(0);

	};

	MissionCleanup.add( %p );

	return %p;
}

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!