Ballistic System (Battlefield series)

Hello

I want to make ballistic system with bullet drops, penetrations a ricochets like is in Battlefield 3 / 4 / 1.
here is sample from YT: Penetration & Ricochet Demonstration Test - YouTube

I have an idea what should i calculate when i want to do ricochets and penetrations.

But idk how to start with raycasts and bullet drops.
If i should use FixedUpdate and every frame use raycast and continue adding new raycast from previous end…

Please give me some advice, how should i do that. I am new in Unity and i would like to learn how to do that.
And sorry for my English. I’m not exactly the best in it. :smiley:

I’ve done similar systems… hunting game, including slow mo, wind, penetration, internal targets etc…
So… you need to ensure your bullet and collision code all works on time deltas. FixedUpdate or regular Update is fine, so long as it uses delta time…
have a bullet speed, generate the inital movement vector when bullet is fired… (moveDirection = the muzzle ‘forward’ vector, normalized)
Then each frame… the bullet will move by moveDirection X bulletSpeed X timeDelta . …also add in gravity vector each frame to the moveDirection .
moveDirection += GravityVector* timeDelta.
also you can do the same with wind if you like … just a small wind push vector to add in.
remember to re-Normalize the moveDirection vector, each frame after altering it with gravity and wind.
Then take that move vector, and the distance its going to move for that frame update, and do a raycast with it… make sure the ray is the length it is going to move that frame, from current bullet position.
raycast forward to see if it hits anything… then if it does… do a raycast backwards to see if it comes out the back of the thing it hit. (if it does, you can add exit vfx there also)
Determine if it can penetrate objects or not, using tags, or layers. (probably tags) or if its a critical hit area from tags also. can also add deflection info in the tag name if you like…
Non penetrating surface can be hard or soft… hard will bounce bullet at low angles… soft will absorb bullet always.
Penetrating surfaces… you can choose if they deflect the moveDirection vector, and by how much (add a random x,y,z vector into movement vector, and re-normalize (just like with wind and gravity)
If you want to get fancy… you can also add in a factor for drag, to slow down the bullet as it travels. You can also try stuff like reducing bullet speed after a penetration… or only allowing N penetrations, then bounce. If you are gonna do slo-mo… have 2 bullet models… clean bullet, and damaged bullet (for after an impact)