Author Topic: Recoil Help  (Read 932 times)

    I need to make it so when you fire my wepeon it make you go backwards like recoil. See I am making it like webs so werever you are pointing when you click you fly in that direction. Any Help is Greatly appriciated, I attached the .cs below.

Code: [Select]
};
function LeaperImage::onFire(%this,%obj,%slot)
{

%obj.playThread(2, none);

%projectile = %this.projectile;
%spread = 0;
%shellcount = 1;

for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};

MissionCleanup.add(%p);
%obj.applyimpulse(%obj.getworldboxcenter(),vectorscale(%obj.getMuzzlevector(%slot), -10 *90));
return %p;
}




}


Quote
MissionCleanup.add(%p);
%obj.applyimpulse(%obj.getworldboxcenter(),vectorscale(%obj.getMuzzlevector(%slot), -10 *90));
return %p;
}

Thanks I meant

%obj.applyimpulse(%obj.getworldboxcenter(),vectorscale(%obj.getMuzzlevector(%slot), 10 *90));
return %p;

But thanks I figuered it out when I am completely Done With it I will give you some credit if you wish.
« Last Edit: June 03, 2008, 02:09:23 AM by Valen »


hey peaceful your a hero member but you dont ahve an avatar? why not?

betcha he lost his rights for avatars

and rank means nothing

I don't have an avatar; so what?

This is kinda an out-of-place discussion :P

I don't have an avatar; so what?

This is kinda an out-of-place discussion :P

Inorite?

hey peaceful your a hero member but you dont ahve an avatar? why not?

I dont care for avatars very much