Realistic Sniper and Ballistics
  • Welcome
  • Introduction
    • Feature List
    • Why/How is it used?
    • Quick Setup
  • Getting Started
    • Getting Started
    • Environment Properties
    • Bullet Properties
    • Object Poolers
    • Sniper and Ballistics System
    • Firing a Bullet
    • Listening to Hit Events
      • Spawning Particles on Hit
      • Hit Tags
    • Zero Distances
    • Wind Vector
    • Air Resistance
    • Spin Drift
    • Ballistic Surfaces - Penetration
    • Ballistic Surfaces - Ricochet
    • Bullet Time Effects
      • Target
      • Bullet
      • Firing with Bullet Time
      • Bullet Time Camera - Default
      • Writing your Own Bullet Time Camera
    • Dynamic Scope System
    • Incorporating Player
      • Player Movement Controller
      • Motion Controller
      • Camera Controller
      • Player With Weapon
    • Mobile Controls
    • Conclusion
  • API
    • API Welcome
    • Sniper and Ballistics System
    • Dynamic Scope System
    • Player Movement Controller
    • Motion Controller
    • Ballistic Surface
    • Environment Properties
    • Ballistics Utility
    • Bullet Time Utility
Powered by GitBook
On this page

Was this helpful?

  1. Getting Started
  2. Listening to Hit Events

Hit Tags

Normally, while writing hit listeners, such as the logic we have written in the previous section, you would want to behave differently according to the hit object's layer or tag. For instance, if it's tagged as "Metal", you'd spawn a metal particle, but if it's tagged "Body" you would spawn a blood particle. The HitListenerSpawnParticle.cs script under the folder InanEvin>Realistic Sniper and Ballistics>src>Hits is doing exactly this. However, introducing tags such as Metal, Dirt, Body etc. for the demo scenes isn't a good idea, as we want to avoid modifying the project settings of the users as much as possible. That's why, under the same folder you can see scripts such as HitTagBody.cs, HitTagMetal.cs, HitTagWood.cs, so instead of checking the hit object's layer or tag, we simply check whether they contain any of these tag MonoBehaviors or not, and spawn particles accordingly in HitListenerSpawnParticle.cs. In your own project, you might want to clearly assign reasonable tags to your objects, so you can check their tags instead of checking for component existence.

PreviousSpawning Particles on HitNextZero Distances

Last updated 3 years ago

Was this helpful?