# Creating a Blast Wave using Line Renderer in Unity

Blast wave is a really cool effect that you can use in your game. Using a line renderer gives a cool horizontal blast effect. In this tutorial, we will see how to create this cool looking effect and the script required to push the objects away when the blast happens.

Here is how the output will look like

## Creating the Line Renderer Effect

The first step is to create the Line Renderer Effect. For this We will be using some mathematics to find out the points on the circle. Then we will increase the radius of the circle and update the Line Renderer’s position.

To find the positions, we need the angle between each point. You can divide 360 by the number of points to get this.

``anglebetweenPoints=360/pointCount;``

Next, we need to get the position in the X and Z as our game is in the XZ plane. We can use SIn and Cos of the angles to get the direction and multiply them with the radius to get the position. As the last position should be equal to the first position, we can set it separately.

``````for(int i=0;i<pointCount-1;i++)
{
positions[i]=new Vector3(Mathf.Sin(angle),0,Mathf.Cos(angle));
}
positions[pointCount-1]=positions[0];``````

We will increment the radius in our update function and set the positions of the Line Renderer.

``````if(radius<=maxRadius)
{
SetPositions();
}``````

## Adding Physics Force to move objects

Now that we have the Line Renderer for the visual effect, we need to add forces to objects within the radius to move them.

We will use the Physics overlap sphere function to find the colliders in the specified radius and add force to them. You need to have Rigid body attached to the colliders to apply the force.

Here is how the code looks like

``````col=Physics.OverlapSphere(transform.position,radius);
foreach(var i in col)
{
}``````

Combining all these codes together and adding the Line renderer to an Empty game object we have our final effect.

Go to the Hierarchy window and create a new Empty game object. Attach the script below to this gameobject and add a Line Renderer. Change the material of the LIne Renderer to the material of your choice and make sure to uncheck “Use World Space”.

Here is the final script

``````using UnityEngine;

public class BlastScript : MonoBehaviour
{
LineRenderer lr;
int pointCount=30;
float anglebetweenPoints=0;
public float speed=10;
Vector3[] positions=new Vector3[30];
Collider[] col;
Rigidbody rb;
float forceval=1;
// Start is called before the first frame update
void Start()
{
lr=GetComponent<LineRenderer>();
lr.enabled=true;
lr.positionCount=pointCount;
FindPoints();

}
void FindPoints()
{
anglebetweenPoints=360/pointCount;
for(int i=0;i<pointCount-1;i++)
{
positions[i]=new Vector3(Mathf.Sin(angle),0,Mathf.Cos(angle));
}
positions[pointCount-1]=positions[0];

}

// Update is called once per frame
void FixedUpdate()
{
{
SetPositions();
ApplyForce();
}
else{
}

}
void ApplyForce()
{
foreach(var i in col)
{