Here we discuss hitscanning in 3D and FPS games, and methods of doing it.
For those who don't know, hitscanning is basically a hitbox collision detection, which determines the speed and height of the body to deal a right amount of damage also depending on distance. It is also used in old games, such as Wolfstein 3D and Doom.
In simple term, if player is jumping the enemy bullets will deal -2 damage. If player is running, the bullets will deal -1 damage. If the player is standing the bullets will deal -8 amount of damage, and if the player is jumping and running the bullets will hit with a rare chance, and so on. This method may not appear useful in 2D games, and the modern games use different methods of calculations.
Why hitscanning?
It improves combat in FPS games, i personally don't use bullet objects in my FPS games but rather deal the damage depending on calculations. If you'd take example as Minecraft, jumping and hitting the pig at the same time will do a critical damage to it.
Since i'm a simple guy and i'm not very much into 3D hitbox detection i've mashed up a very simple (very very simple) code, it can be improved for sure;
if obj_player.speed>0
{
//Insert any shooting variables here, make sure to set the damage amount for each action
speed = 0; obj_player.health -= 2 }
else
if obj_player.speed<1
{
speed = 0; obj_player.health -= 5
}
else
if obj_player.zspeed > 1
{
speed = 0; obj_player.health -= 1
}
}
Again, this is VERY basic, since it's quite a noob thing let's take it as an example.
The purpose of this thread is to share the methods you guy's may use, it may be an advanced script, or just as simple method as i did.
(These images are off the Wolfstein Wikia, i thought this may come useful!)
Hit detection

Damage calculation

Graph
![]()
Damage Formula (Player shooting)

What are better methods of doing this?



Find content
Male
