• Register

Fursan al-Aqsa: The Knights of the Al-Aqsa Mosque® is a Third Person Action Game on which you play as Ahmad al-Falastini, a young Palestinian Student who was unjustly tortured and jailed by Israeli Soldiers for 5 years, had all his family killed by an Israeli Airstrike and now, after getting out from the prison, seeks revenge against those who wronged him, killed his family and stolen his homeland, by joining a new Palestinian Resistance Movement called Fursan al-Aqsa: The Knights of the Al-Aqsa Mosque®. Fursan al-Aqsa® is a Registered Trademark of Nidal Nijm Games © 2022, all rights reserved.

Post news Report RSS Fursan al-Aqsa Dev Blog #13 - Fixing the Aiming System

In this technical article I explain step by step how I was able to fix the most significant bug of my game, which could, for some players, break the gameplay.

Posted by on

User Posted Image

I know my game is not perfect, but I can assure it has less bugs than #CyberBug 2077 :) :) :)

Yesterday, after an entire night asleep and with the help of Allah (God), I was able to solve the most significant bug of my game. This bug was there since the first demo, and I tried to solve it many times without success. Then, as any other dev, I put it on my TODO LIST.

However, I was talking with a friend of mine, who recently downloaded and tested the last demo (Infiltration), and he told me although he liked my game, but the aiming bug spoiled his enjoyment with my game. This made me think too much on the matter. So I decided: It's time to put my dirty hands to solve this shit :)

The bug in question, is that sometimes, if the player is too much close to some wall, or any level geometry object, the projectile simply is not launched from the weapon, which results in too much frustration for the player, because he is aiming towards the enemy and the bullets don't hit the target.

The advantage of UDK Engine, in my case, is that it comes with the entire source code (unreal scripts) of Unreal Tournament 3, making it the perfect engine for making a shooter game (you can create ANY kind of game with UDKEngine, but you have a shooter template outside the box).

User Posted Image

I did read the entire UTWeapon.uc script, which controls all the functions of a weapon in Unreal Engine 3 (in case UT3). So I came to the origin of this bug:

The function is:

simulated function vector GetPhysicalFireStartLoc(optional vector AimDir)

And the line of code is:

FireStartLoc = Instigator.GetPawnViewLocation() + (FireDir * FireOffset.X);

Even if you don't understand UnrealScript, but is very simple to have an idea of what's happenning.

The FireStartLoc is the initial position of the projectile (in case the weapon bullet), and it's calculated taking into consideration the Player Camera (PawnViewLocation). I asked myself, why the fuck EPIC Games did this way? It`s because Unreal Tournament 3 is a First Person Shooter, so it makes sense to use the player point of view for calculating the projectile start point.

User Posted Image

But as I changed the camera for my game (Third Person), so whenever the player is pressed behind a wall, the camera changes to avoid colliding with the wall, so it kinda loses the PawnViewLocation, resulting on the bullet not being ejected from the weapon.

So after a lot of trial and errors, and trying to use other calculations and formulas on this same class (UTWeapon.uc), I replaced that line of code by this:

//FireStartLoc = Instigator.GetPawnViewLocation() + (FireDir * FireOffset.X);
FireStartLoc = Instigator.Location - FireDir*FiredProjectileClass.default.CylinderComponent.Translation.X;
FireStartLoc.Z = FireStartLoc.Z + FMin(Instigator.EyeHeight, Instigator.CylinderComponent.CollisionHeight - FiredProjectileClass.default.CylinderComponent.CollisionHeight - 1.0);

Voila!!! The projectile now is fired from the weapon regardless the player position!!! Problem solved? Not yet.

These new formulas solved the problem in 95%, then I just needed to make a small adjustment on the crosshair screen position, to make the projectile hit the center of the crosshair. But I needed to make 2 adjustments, one for First Person View, and another for Third Person View.

User Posted Image

The function is:

DrawWeaponCrosshair( Hud HUD )

if( Instigator != none )
{

PC = UTPlayerController(Instigator.Controller);

//this will check if is FPS view
if (PC.bBehindView == false)
{
//ScreenX = X - (CrosshairSize.X * 0.5);
ScreenX = X - (CrosshairSize.X * 0.5);
}

//this will check if is TPS view
else
{
//ScreenX = X - (CrosshairSize.X * 0.5);
ScreenX = X - (CrosshairSize.X * 0.5) - 10;
}

}

ScreenY = Y - (CrosshairSize.Y * 0.5);

Now I finally solved this bug which was torturing me from a long time.

And as a plus, now the bullet time effect has a more important function than just the cosmetics. Because I had to increase a bit all the guns projectile speed, to make the aiming system more accurate, so now the bullet time slow motion effect can trully help to deviate from the bullets.

Last, but not least, making headshots now is a breeze!

User Posted Image

Cheers and until next update!

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: