I’ve been searching for the best way to implement a tank armour system more specifically how would I define the armour thickness on tanks, I’ve seen all sorts of types UV Mapping, Physics Assets, Physical Materials, etc. but I don’t know the best way, also I am open to C++.
i’d separate the concerns.
have something to detect what was hit, ie front/back/turret (Possibly Physical Materials since you can return it on trace)
have something to define what armor is, ie a struct with type, thickness, damage reduction etc
and finally something to calculate damage, like a function library
Seperating systems is good, depending on how much realism you consider in your game design of systems varies.
To start with you have a weapons system (let’s keep it simple)
- WeaponsSystem
- Helpers (Movement, Equip, Unequip etc.)
- Deployment
- AmmoManagement - > InventorySystem
- Projectile
- Impact
and you have and ArmorSystem. Armor system is listener of the Weapons System and its results.
WeaponSys → ArmorSys
Meaning it shouldn’t be talking directly with weapon but just listening the Impacts and processing them.
So depending on the impact can be many things (depends what you have and design)
- WeaponsSystem
- Impact
- Impact Type
- SingleHit (doesn’t penetrate)
- Penetration (penetrate either with thickness or per surface)
- Blast (Single hit on impact + penetrate either with thickness or per surface)
- Damage Type
- True Damage
- Piercing Damage
- etc.
- Impact Type
- Impact
and armor system
- ArmorSystem
- ActiveArmor
- PassiveArmor
- Steel ( Decreases penetration or blast damage per surface by %x)
- Tungsten ( Decreases penetration or blast damage per surface by %x for Piercing Damage and full protection agains True Damage)
So after these rules simply your Weapons System should behave and talk with armor system accordingly. Sometimes depending on how you design system and deployment of weapons it can be projectile, deployment or impact making these, still its advice to use an abstraction on impacts.
This means a projectile will always hit some objects with penetartion but doesn’t really do something on execution. Which makes system more managable.
If you want something more realistic it needs to resolved in Armor system 1st then callback to projectile again so that projectile can decide whetever they should continue movement or stop destroy(). This aspect defines the “ShouldPenetrate” aspect of the projectile flight but can be done other way as said. It just overlap impacts and ArmorSystem itself can decide what happens since it’s more easier to design, understand, debug and faster calculation.
Ex: You deploy a 50 Cal bullet-> Projectile Flies (True Damage, Penetration, Damage Fall over Distance) → Overlap → Impact()-> ShouldPenetrate → Overlap → Impact() → DestroyProjectile()
There is 2 impacts on some objects
1st lets say active armor
Impact() → BeginPlay()->Object TryDoDamage( TrueDamage, X amount of Damage,Piercing)
2nd lets say passive armor (Tungsten upgraded)
Impact() → BeginPlay()->Object TryDoDamage( TrueDamage, X amount of Damage,Piercing)
Armor System
OnDamageReceived → Explode() → Destoy()
OnDamageReceived → CanDoDamage() → False(Since its Tungsten) ->DoCosmeticBlocking(SFX,VFX etc)
and Penetration mechanics.
This can be just physical material and you can derive density from it with objects bounds. Then you can calculate the amount of travel through this object and how much damage it should loose until it exits and enters next (if can). That would also need to respond to the angle of attack which is impact normal that can influence the armor by maybe with a basic curve with a Snell equation, however this is generally too realistic I find, its too overloaded generally types and damage types will solve it nicely. Unless you are not doing a military simulation.