Author Topic: how to make screen shake?  (Read 1173 times)

How do you make the screen shake when you fire a projectile?

And also, could someone explain to me how projectile spread works and how to use it?

I am not sure about the screen shaking.

To spread projectiles, lets look at the TF2 Minigun...

Code: [Select]
function TF2MinigunImage::onFire(%this,%obj,%slot)
{

%projectile = TF2MinigunProjectile;
%spread = 0.04;
%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) * 0.8 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 0.8 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 0.8 * 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);
}
return %p;
}


These would be your main thing to spread them:

   %projectile = NamedProjectile;
   %spread = HowShouldItSpreadOut;
   %shellcount = 1; //Keep this the way it is unless you want more than one shell

How do you make the screen shake when you fire a projectile?

Spawn an explosion.

Code for rocket launcher, pay attention to what's in bold..

datablock ExplosionData(rocketExplosion)
{
   //explosionShape = "";
   explosionShape = "./explosionSphere1.dts";
   soundProfile = rocketExplodeSound;

   lifeTimeMS = 350;

   particleEmitter = rocketExplosionEmitter;
   particleDensity = 10;
   particleRadius = 0.2;

   emitter[0] = rocketExplosionRingEmitter;

   faceViewer     = true;
   explosionScale = "1 1 1";

   shakeCamera = true;
   camShakeFreq = "10.0 11.0 10.0";
   camShakeAmp = "3.0 10.0 3.0";
   camShakeDuration = 0.5;
   camShakeRadius = 20.0;


   // Dynamic light
   lightStartRadius = 10;
   lightEndRadius = 25;
   lightStartColor = "1 1 1 1";
   lightEndColor = "0 0 0 1";

   damageRadius = 3;
   radiusDamage = 100;

   impulseRadius = 6;
   impulseForce = 4000;
};

-snip-
This is kinda right, but you need to make a separate explosion that is invisible and shakes the players camera, then you need to spawn it in the players face when he fires