# Firing a Bullet

In order to fire, we need to call a single method on **SniperAndBallisticsSystem** instance. First let’s create an empty game object and name it **Tutorial.** Then create a new script, name it **Tutorial.cs** and then attach this script to the Tutorial object in your scene. Open up the **Tutorial.cs** script. In order to use RSB classes, we first need to include a using **IE.RSB** directive at top of our script.

{% embed url="<https://gist.github.com/36d755a8e7763655a08388c75ee5640f.git>" %}

Then, inside our class, we will need to reference the bullet properties asset file we’ve created to use it while firing.

{% embed url="<https://gist.github.com/bdb394e22933ef181bf30d4048bedd6f.git>" %}

In order to be able to fire a bullet, we first need to **activate** it. Activating a bullet triggers a set of functions to pre-calculate some bullet variables such as it’s drops or zero angles, which are needed during&#x20;

simulation. By activating the bullet first, we avoid calculating these variables in runtime, saving us a performance. To do so, we will need to call a method in SniperAndBallisticsSystem instance. This is a singleton instance, meaning that it can be accessed from anywhere in your scene as long as one instance is attached to an object in the scene, which is the case for us.&#x20;

{% embed url="<https://gist.github.com/ca3e8dcc2f48c26861a7c82cc01c33bd.git>" %}

It is a good idea to activate the bullets in **Start** function, since we make sure SniperAndBallisticsSystem singleton instance will be definitely available to use in Start. We call the **ActivateBullet** method, pass in our bullet properties instance. You need to do this in start function for every type of bullet property you plan to use in your scene. Usually this will be only for a single bullet, but for instance if your game has different ammunition on different weapons, you can write a script that will create a list of bullet properties references and iterate over them to call the function above in Start for all of them.

Next, let’s fire this bullet! Let’s setup a block in our update so that we can fire when we press **Space** key.&#x20;

{% embed url="<https://gist.github.com/35160235b923131fc8dc5cbd34ea5efd.git>" %}

Now, only thing we need to do to call FireBallisticsBullet method to fire our bullet defined by myBulletProperties.

{% embed url="<https://gist.github.com/16974fb64069fa7283b05dfb443f5916.git>" %}

And that’s it! Now if we go to the **Tutorial** object we have attached this script, and drag & drop our bullet properties asset file as the reference to **myBulletProperties** variable, we will be good to go!

![](https://lh6.googleusercontent.com/y9bOCBMLVauS93av8vjVjP5xRLOHjSChxuUZ_4FCWGZJD7ooW6Xjb1KKQiVeZ-2gU01EOnIBCzcmkw2Dh-LvJvfaG1wp9nvpliXTmvuqsJxxZ6R8lCmxr_ivN4i0DDy399Cy-g_A)

If we play the game and hit **space** key the system will fire from the **main camera,** because that was what we have attached as the **Fire Transform** variable in SniperAndBallisticsSystem instance. We can see the bullet trajectory in scene view since we have enabled ray debugging.

![Scene view showing the trajectory of the bullet fired from main camera.](https://lh5.googleusercontent.com/HaD30GK3mqylyxQaLhxaQsO7vFvzve0xBcSH5m8adsC2bOB6x5twPbK9IIBJzY3vTcyWyj3uVBKhb46P8UCXVBN0vaCWL6zEQFo0JdY7apNUyDtx8ydSp6veRmiUpy_yoYs1oaws)

We have fired our first bullet which is ballistically simulated! Now let’s learn how to listen to hit events for this bullet, so that we can cast particles, or apply forces to rigidbodies that are hit.
