Gravity Gun
by SqHd · in Torque 3D Professional · 08/12/2014 (7:49 pm) · 0 replies
I was wondering if anyone has the know how to alter the Gravity Gun (from an early T3D demo) to pick up a single PhysX object, hold it, and allow you to put it back down (similar to Portal). Currently, it acts like a suction machine and just pulls PhysX objects towards the player and kind of throws them away. Thanks for reading!
// GravityGun weapon.
function GravityGunImage::onFire(%this, %obj, %slot)
{
//echo("WeaponImage::onFire( "@%this.getName()@", "@%obj.client.nameBase@", "@%slot@" )");
// Gravity Gun has infinite "ammo".
//%obj.decInventory(%this.ammo, 1);
%vec = %obj.getMuzzleVector( %slot );
%start = VectorAdd( %obj.getMuzzlePoint( %slot ), "0 0 0.2" );
%end = VectorAdd( %start, VectorScale( %vec, 100 ) );
%impulse = "0 0 0";
%hit = castForceRay( %start, %end, %impulse );
if ( %hit !$= "" )
{
%impulse = VectorScale( %vec, -15 );
castForceRay( %start, %end, %impulse );
}
return "";
}