Monday, February 20, 2017

45. Blood Splatter Test in Starship Troopers?



       This is based off the starter-kit by Hardworker Game Studios which is outdated. I have updated it and re-programmed it in my game engine built upon the XNA 4.0 and MonoGame Fraweworks with the added blood-splatter. It runs on Windows 7, 8 and 10. This program also can run on other platforms supported by MonoGame. The models are simply just a placeholder. This is the beginnings of the AI which is set to simply wander for now.


How do Bullets Work in Games?

Hitscan
       Like the earlier days, the bullets are rendered through a technique called ray-casting. Ray-casting allows the engine to determine the first object intersected by a ray. The majority of games just cast rays along the bullet trajectory to see if there is any collision. This works well since the size of the bullet is usually tiny compared to the size of the world. Many games program bullet sprites (2D images) rendered in 3D which are cast along the ray to provide a visual to the player of bullet projectiles being fired. This also helps with performance. So most cases, game developers find physically modelling a bullet usually pointless. Bounding spheres are attached to the bones of the enemy models for hit detection. So when the ray intersects the bounding spheres, the blood particle effect is emitted. To learn more about implementing ray-casts in your own game projects, check out the Triangle Picking Sample.

       Popular games that use hitscan are Wolfenstein 3D, Doom, Overwatch, Halo and Call of Duty. One of the biggest disadvantages of ray-casting is that the rays have an infinite traveling velocity. Regardless of the range, the rays reach their destination instantly. This ultimately means there is no travel time after you fire a bullet and hit an object. This is not the best method depending on the type of gun used in a game that's based on realism because if the enemy target is miles away, it's impossible to dodge a bullet. In other words, a pistol would have the shooting range of a sniper. Most implementations of hitscans use straight rays. This makes it hard to take into account wind, gravity and other external factors that may affect the bullet once it leaves the gun. So once a player fires their gun, there is no real way to modify its path in the middle. For a "casual" gamers like myself, the hitscan method is a simple learning curve especially for beginner players. However, for games that aim to create an "immersive realistic" shooting experience, the hitscan method creates constraints for their players. This brings me to the next popular method. 


Projectile Ballistics 
       Soon, I plan to run some tests to where the bullets are actual 3D models that will intersect the bounding spheres of the enemies. Why you might ask? In one of my long-term game projects, the modelling of gravity, wind and resistance on the bullet is important as well as seeing bullets being deflected in real-time. With projectile ballistics, every bullet or projectile shot our of a weapon creates a new physics object in the environment. It has its own mass, velocity and hitbox that the game engine will track. This is a priority in games where realism is praised. The drawback to projectile ballistics is that there are additional computations and more processing required in comparison to the hitscan method which is less taxing. Also, game servers will have to make a greater effort making sure all the objects are in sync and remove any conflicts across clients to create smooth multi-player online experiences. 

      Popular games that utilize projectile ballistics are Max Payne and Sniper Elite. Max Payne is known for their popular "Bullet-time" system. Projectile Ballistics is also handy for travel time when taking a long-distance shot or delayed explosions for grenades. For now, I am using the hitscan method. I have also added audio for the gun-fire. Later I plan to add my physics engine and the animated mutant spider beast models. I did not add my physics engine just yet because the terrain was outdated and I didn't want the player as well as the enemies falling infinitely. Once my physics engine is added, the hit detection will be far more accurate. Hopefully I will have the real-time fur effect implemented on the animated spider beast model soon.


Hybrid Systems 
       Many game engines today utilize both hitscan and projectile ballistics. This allows their games to implement a huge variety of weapons. Games such as Halo and Half-Life have weapons that support both these types of physics systems. In Halo, the popular Assault Rifle uses the hitscan method and the Needler uses projectile ballistics. What I've always found unique about the Needler and heat-seeking missiles in flight games is their tracking abilities. The Needler only tracks when the reticule is red which is also true for some flight based games when they lock onto their targets within range. Whenever you're in combat against the Needler, it is smart to go behind cover to block the needles. If you have a long range weapon, or just want to avoid the Needler completely, then be sure to keep your distance away from the enemy using the Needler.















Source Code:



What's All Included: 
1.Basic Rendering system with basic effect.
2. Particle System.
3. Basic object management.
4. The XNA Terrain Library is outdated so I will add my own terrain from my game engine later
5. The XNA 4.0 Skinned Model Sample Pipeline (The Cyclone Game Engine's XNAnimation Library will be used instead in the future to replace this)
6. Anti aliasing 4X
7. Gun-Fire Sound Effect


No comments:

Post a Comment