Game Development Community

Adding Weapon Zeroing Effect

by Zorro Davis · in Torque Game Engine · 01/05/2016 (3:56 pm) · 1 replies

Greetings, I wanted to add a effect to the weapon or Projectile to simulate a Zeroing effect for your weapon when dealing with Bullet Drop. I been trying to figure the math but I just cant quite get it where I want it.

I use this:

%shellcount = 1;
%spread = 0.001;
for(%shell=0; %shell<%shellcount; %shell++)
{
%ZeroInADS = %obj.client.quantity["Zeroing"];
switch$ (%obj.client.quantity["Zeroing"])
{
case "":
%obj.client.quantity["ZeroHUD"] = 0;
case "0.05":
%obj.client.quantity["ZeroHUD"] = 50;
case "0.1":
%obj.client.quantity["ZeroHUD"] = 100;
case "0":
%obj.client.quantity["ZeroHUD"] = 0;
}
%speed = %obj.client.quantity["Power"];
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %speed);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread + %ZeroInADS;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread + %ZeroInADS;
%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.getEyePoint();
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);

The Problem is when I shoot, the projectile will only rise in specific directions. If im facing the X axis it will do the effect I wanted, but if im 180 from the X axis, the bullet will drop instead of Rise up.

I was inspired by playing Battlefield 4 for the first time and I wanted more ballistics in my game.