Getting Started
Check out the included example scene in the Ballistics/Example/ folder.
Minimal Setup
- create a
Assets/Create/Ballistics/Ballistic Settingsobject in your project folder - add an empty game object to your scene and attach a
Environment Providercomponent to it- assign the
Ballistic Settingsobject you have created before
- assign the
- attach a
Weaponcomponent to a weapon in your scene- assign a transform at the end of the weapon barrel as the
Bullet Spawn Point(z-axis pointing forward) - create a
Assets/Create/Ballistics/Bullet Infoobject in your project folder - assign this
Bullet Infoobject in theWeaponcomponent
- assign a transform at the end of the weapon barrel as the
- calling
Shoot()on theWeaponcomponent will fire a bullet (you can use theSimple Weapon Inputcomponent, to shoot when clicking the left mouse button)
Note! As so far no impact handler or visual bullet provider is set up, you will NOT see the bullet or any impacts!
Visual Bullet Provider
Bullet Ballistics separates the ballistics simulation from the visual projectiles flying through the scene. This allows to optimize the rendering when thousands of projectiles are active simultaneously, and allows you to customize the rendering to your needs.
- create a
Assets/Create/Ballistics/Visual Bullet Providers/Pooled Bullet Providerobject, and assign a bullet prefab with aPooled Bulletcomponent attached - assign the new
Pooled Bullet Providerobject to theVisual Bullet Providerfield of your weapon
You should now be able to see the bullet prefab when shooting the weapon.
Impact Handler
Similar to the Visual Bullet Provider the Impact Handler allows you to customize what should happen on a projectile impact.
- create a
Assets/Create/Ballistics/Impact Handler/Generic Impact Handlerobject in your project folder- assign the impact handler object to the
Global Impact Handlerfield of yourEnvironment Providercomponent
- assign the impact handler object to the
- enabling
Handle Rigidbody Forcesshould cause rigidbodies to be affected by projectile impacts - adding a audio clip to the
Impact Soundslist, will cause an impact sound at any impact of a projectile with the scene
Ballistic Materials
Ballistic Material define how a projectile will behave when interacting with a collider.
- create a
Assets/Create/Ballistic/Ballistic Materialobject in your project folder- a Ballistic Material is a unity
Physic Materialwith an associatedBallistic Materialobject - you can promote/demote a
Physic Materialto/from aBallistic Materialby right-clicking thePhysic Materialand selectingAssets/Create/Ballistics/To BallisticMaterial/Unlink BallisticMaterial
- a Ballistic Material is a unity
- assign a Ballistic Material to a collider by setting the
Materialfield of the collider to aPhysic Materialassociated with aBallistic Materialobject - by change the properties of the Ballistic Material to alter the bullet interactions
For more information on each of these topics check out the following chapters.