Background and Developers

After waking up a mysterious island with no recollection of how you arrived, you are driven by the basic human instinct to survive. Gather resources, build shelter and live off the land. Tame animals and explore the island. Hunt or be hunted. But most importantly: Survive. However you can.

Wilderness is an open world survival game in development by Dark Window Studios, a dedicated team of developers based in the UK. It is being developed on the flexible and powerful Unity3d game engine with tools like Photoshop, Blender and MakeHuman. Wilderness is planned for a Steam Greenlight in late 2017, with Steam Early Access following soon. Check back regularly for updates and changes. Welcome to the Wilderness.

Backers

These individuals have backed Wilderness from very early stages of development. Without them, Wilderness wouldn't be possible.

  • A. Dermont
  • J. Prescott
  • A. Shaz
  • S. Bramwell
  • P. Steane
  • I. Ahmed

Preorder

Preorder is now availiable via the Humble Bundle Store. However, before purchasing, remember that this game is in Early Access and that this current state does in no way represent the final product. There will be unpolished features, bugs (minor and game-breaking), many minor updates and potentially game-changing updates. If you are not happy with this, then please wait until the game is out of Early Access.

Humble Bundle

Steam Store

Web Links

Website, Facebook, Twitter, Reddit, Forum, Trello Roadmap, Steam, Presskit

© Dark Window Studios Ltd. 2015-2016, All Rights Reserved

  • View media
  • View media
  • View media
  • View media
  • View media
  • View media
RSS feed Articles

Bullet Penetration

Feature 0 comments

Introduction

Bullet penetration is something that is very common in today's AAA games. However, it isn't as common in Indie games as it should be. Settings up a basic system, like the one we use, took about a week and a half, but the result is another layer of immersion and realism. The idea of having bullet penetration may seem like a very complicated subject, having to take many values into account, such as bullet velocity and damage, but thanks to Unity, it can be a lot easier than first anticipated. For our approach, we decided to use raycasting but there are other approaches, such as particle systems.

Bullet Penetration (5.56x45)

As this picture shows, the bullet has declining damage and velocity, which is indicated in the colour strength (Green being high velocity/damage, Red being low velocity/damage). As the bullet passes through each material, the velocity is reduced depending on the material. Here is a comparison of a 9x19mm bullet vs. a 5.56x45mm bullet.

9x19mm Parabellum bullet:

9mm Bullet Penetration

5.56x45mm NATO bullet:

Island 01 11 2016 15 21 screensh

The 9mm bullet fails to punch through two layers of wood, but the 5.56mm bullet powers on through more than 5 layers.

How we did it:

Lets get right into it. Before programming a solution, we needed to set up tags. We already set up a few named "Wood", "Concrete", "Water", ect. for differentiating our footsteps on different materials. However, we want more precise control over material penetration, so we set up a few more tags named "WoodThin", "WoodThick", "ConcreteThin", "ConcreteThick", "MetalThin", "MetalThick" so we could have different penetration values for the same material. We originally looked into calculating the mesh width at that particular angle, but it wasn't practical for runtime. However, Unity has very handy function named Physics.RaycastAll. This sends a ray through all objects for a specified range, logging each collider hit.

Ray ray = new Ray(cam.position, direction);
RaycastHit[] hits = Physics.RaycastAll(ray, 1000.0f);

This returns an array of RaycastHits, a struct that contains information about the hit point and collider that was hit. We can then loop through each of the hits and check information from them.

foreach (RaycastHit hit in hits)
{
     if (hit.collider.tag.ToLower() == "dirt")
     {
          // Do stuff here
     }
}

This is an easy way to loop through the hits and check information. However, we need to record the bullet's current velocity and damage. We just do this via two floats, currentDamage and currentVelocity.

float currentVelocity = 1f;
float currentDamge = 1f;

To simply things, we made a data class named BulletPenetrationStats. This class has a simple constructor, taking in the tag name as a string, bullet damage reduction value, bullet force reduction value and a minimum velocity to penetrate value.

private class BulletPenetrationStats
{
     public string m_sTag;
     public float m_fDamageReduction;
     public float m_fVelocityReduction;
     public float m_fMinimumPenetrateForce;

     public BulletPenetrationStats (string tag, float damageReduction, float velocityReduction, float minPenetrationForce)
     {
          m_sTag = tag;
          m_fDamageReduction = damageReduction;
          m_fVelocityReduction = velocityReduction;
          m_fMinimumPenetrateForce = minPenetrationForce;
     }
}

Earlier in our weapon script, we can declare a private array of variables for each kind of bullet we want, like 9mm High Velocity or 9mm Armour Piercing. For the moment, we just have 9x19 and 5.56x45 rounds balanced and in-game.

private BulletPenetrationStats[] nineMilimetreRoundStats = new BulletPenetrationStats {
    new BulletPenetrationStats ("WoodThin", 0.2f, 0.1f, 0f),
    new BulletPenetrationStats ("Wood", 0.4f, 0.4f, 0.2f),
    new BulletPenetrationStats ("WoodThick", 0.6f, 0.7f, 0.3f),
    new BulletPenetrationStats ("ConcreteThick", 1f, 1f, 1.1f),
}

These aren't representative of the real stats, but a quick example of how we set up the data.

Then, we check at the end of our foreach bracket, looping through the stats and taking away the velocity and damage values. Finally, we check that they are above zero, otherwise we return out of our Shoot function.

BulletPenetrationStats currentStats;
foreach (BulletPenetrationStats entry in nineMilimetreStats)
{
     if (entry.m_sTag.ToLower() == hit.collider.tag.ToLower()
     {
          currentDamage -= entry.m_fDamageReduction;
          currentVelocity -= entry.m_fVelocityReduction;
          currentStats = entry;
          break;
     }
}
if (currentVelocity <= 0 || currentDamage <= 0 || currentVelocity <= currentStats.m_fMinimumPenetrateForce)
{
     return;
}

However, I'm very pedantic about little details. I wanted bullet holes on both sides of the object, so that you could visually trace the path of the bullet. As this foreach statement is run in a single frame, every object is static, so we don't need to worry about accidentally hitting a different object. A single Physics.Raycast will suffice, saving much needed performance on the server side. To calculate the Raycast angle, we just need to take the last hit point away from the current hit point, to get the exact angle needed for the bullet hole on the other side.

Vector3 startPos = hit.point;
Vector3 endPos = lastHitPoint;
Vector3 dir = startPos - endPos;
Ray ray = new Ray(transform.position, dir);
if (Physics.Raycast(ray, 1000f)) {
     // Check surface and instantiate bullet hole
}

Conclusion

And that is a very brief and simple introduction to bullet penetration. It will definitely be taken further and expanded, but this is the depth and complexity required at the moment. One way to expand it would to have a custom shader that has different penetration values, so you could adjust them for each material, but that's an idea for the future. Thanks very much to IRetrograde, who explains it in much more depth than I could. A very handy article on bullet penetration by him can be found here.

Remember to check our Trello Roadmap for real-time updates and follow us on Twitter. Keep Surviving!

Matt

Dark Window Studios

© Dark Window Studios 2015-2016

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Icon
Wilderness
Platforms
Windows, Mac, Linux
Developer & Publisher
Dark Window Studios
Engine
Unity
Contact
Send Message
Release date
Game watch
Start tracking
Share
Style
Theme
Realism
Project
Indie
Twitter

Latest tweets from @wildrnsupdates, @wildernessgame

Fixed bug where dropping item wouldn't remove item from inventory

Aug 22 2016 by wildrnsupdates

Fixed a bug where quick select on hotbar would be offset by 1 - DWSMatt

Aug 20 2016 by wildrnsupdates

Fixed bug where inputs would show under incorrect headings, added more buffs and added picking up items - DWSMatt

Aug 20 2016 by wildrnsupdates

UNet Development: Added hotbar selection logic - DWSMatt

Aug 19 2016 by wildrnsupdates

Added buff and debuff framework - DWSMatt

Aug 19 2016 by wildrnsupdates

UNet Development: Fixed bugs - DWSMatt

Aug 15 2016 by wildrnsupdates

Upgraded to Unity 5.4.0f3 - DWSMatt

Jul 30 2016 by wildrnsupdates

Unet Development: Added cancel connection dialogue and fixed a few dedicated server issues - DWSMatt

Jul 29 2016 by wildrnsupdates

UNet Development: Added dropping items in the world - DWSMatt

Jul 25 2016 by wildrnsupdates

UNet Development: Crafting Queue is now saved and loaded and the game settings for crafting now has impact - DWSMatt

Jul 18 2016 by wildrnsupdates

Embed Buttons
Link to Wilderness by selecting a button and using the embed code provided more...
Wilderness
Statistics
Last Update
Watchers
6 members
Articles
1