Jump to content
  • Advertisement
  • entries
  • comments
  • views

Projectiles, Bounciness and Penetrability

Sign in to follow this  


[font=arial]Floatlands has another addition - Projectile system. Until now, only weapon animations were present in the game, without actual bullets, so the shooting experience wasn't quite genuine. This chapter will go over projectiles that launch from a weapon, how they bounce from other objects and surfaces, and how much effect do penetration angles have.[/font]

[font=arial]The projectiles are drawn with a white line. Velocity verlet integrator was used for simulating bullet forces because it produces almost no error and is simple to implement. If you wish to learn about verlet velocity, this is good article to read: [/font][font=arial]Doing gravity right[/font]


[font=arial]Projectiles also support bouncing off the surface. If the angle between a bullet and a normal is right enough, the bullet will bounce otherwise it will stop. Random error is added to velocity after bounce too, so that it's path is less predictable. Shooting bullets into cave gets interesting, because bullets bounce to every imaginable direction.[/font]


[font=arial]Lots of games don't have this feature of Projectile penetration, it's a very good gameplay element and this is why it was added. It becomes very fun to play, because you can damage an opponent through a wall. Lets look at some examples, so you can get a taste of what this feature can do.[/font]

[font=arial]Penetration calculation includes a huge amount of math. Angle between a normal and projectile direction tells you how orthogonal to surface the bullet is. There is more chance that a bullet will penetrate, if it is orthogonal to the surface. Also, each projectile loses "mass" so that its weaker after penetration. It can also happen that a bullet doesn't penetrate but bounces off instead.[/font]



There is also another raycast from another side of collider, (reverse direction of bullet) so that code can determine how deep penetration will be. The deeper, the less chance that it will penetrate (or not at all).



[color=#424242]From this little experiment it's visible that triangle walls are much more protective against bullets than just straight quad walls.[/color]

[font=arial]A little bit of programmers speak:[/font]

[font=arial]Every MonoBehavior that will be penetratable needs to implement this IPenetratable interface. Then you can just call GetComponent() on collider and if it's not null, you can go on and calculate penetration from porosity and max depth.[/font]public interface IPenetratable{// [0, 1] - measures emptiness of volumefloat GetPorosity(); // (0, +inf)// max depthfloat GetMaxPenetrationDepth();}

[font=arial][color=#424242]Game also includes dynamic crosshair; it reacts to player velocity. Here you can see the crosshair of shotgun reacting in action.[/color][/font]






  • Bullet spread: How much spread independent of current state. Shotgun projectiles still spread even if you crouch.
  • Weapon spread: How much player movement affects weapon accuracy.
  • Recoil kick: How much it moves your crosshair/mouse permanently.
  • Recoil kick deviation: Randomized kick ammount (deviation is from statistics).
  • Recoil deviation: Temporary displacement of your cursor. This is usually big because it returns to back where you were aiming exponantially fast.


Sign in to follow this  


Recommended Comments

That was an interesting ..experience! Well written. I mean wow, bouncing bullets, why haven't other games had that? Because you're right, they haven't! And it looks like a really fun thing to play with. You could use some decent 3D positional sound effects to give players a grasp of where the bullets fly. Maybe you would you show tracers too.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!