# Getting started

The easiest way to understand the basics is to create your first Force Field object.  Let’s get started with a new scene and a few things to help us along. We will use one object to render the shield effect and the other to render a surface it covers.&#x20;

### **Creating geometry**

* &#x20;Create sphere from Unity menu **GameObject -> Create Other -> Sphere** and place it in front of the camera

![](/files/-MAuGuG1rB_WH2DyE0eE)

* &#x20;Duplicate the Sphere game object using **Edit -> Duplicate** menu and rename it to “**Shield**“. Select Sphere game object and remove Sphere Collider component.

![](/files/-MAuH37ANRTbQMwJU8nj)

### **Adding a controller**

Next thing required is a controller script. Let’s add one to the Shield and assign the game object reference to be used as a shield surface.

* Add **Forcefield.cs** script component to the Shield game object using the inspector’s “**Add Component**” either manually from **Assets/FORGE3D/Force Field/Scripts** folder by dragging it on top.

![](/files/-MAuHBekBSou4bhkAf33)

* Select Shield game object in the Hierarchy panel and drag it on top of the empty ‘**Field**‘ property of the Force Field Controller within the Inspector.

![](/files/-MAuHD5fHNA5FNOR5HLX)

### **Adding a material**

It’s time to create a new material and assign it to the Shield. We will use Force Field shader to render the shield and the corresponding effects.

![](/files/-MAuHJjjGXoZXpmy-Fnk)

* Create new Material in Project panel: **Right Click -> Create -> Material** and name it “**Shield**“.
* Select the material and pick **FORGE3D/Force Field/Force Field** shader from the drop down list.

### **Shader setup**

Force Field ships with a set of textures to help you create various kinds of shield effects. In this chapter, we will set the shield, its colors, and different properties so it looks and feels the way it should.

* Plug the texture mask into the Field Texture slot, such as “**field\_charge\_003**“, which can be found under the **Assets/FORGE3D/Force Field/Textures** path, and set the texture tiling to 8 on X and 4 on Y  to help the spherical shield appear in a more pleasant way.

![](/files/-MAuHU0qtfEnto8Al8yc)

Next important step is to set up a shield color gradient with help of both Inner and Outer Masks Tints. Note the alpha value is used to boost the multiplier, and it is vital to get it shine with your juicy Glow Image Effect.

* Set ‘**Inner Mask Tint**‘ RGBA color values to (**R: 130, G: 220, B: 255, A: 40 /** **HEX Color #82DCE128**)
* Set ‘**Outer Mask Tint**‘ RGBA color values to (**R: 0, G: 150, B: 255, A: 40 / HEX Color #0096FF28**

![](/files/-MAuHVg4nTu8Wurd2Ck8)

The “**Mesh Offset**” will push the shield along its normals and the “**Pan Speed**” will animate the texture so you shield looks more like alive. So leave the positive default values as it is more than enough for our purpose.

![](/files/-MAuHXHRNE3BZHbQUA-w)

Now it’s time to set shield feedback at the moment of impact. “**Background Visibility**” is the first layer that makes the effect.

* Set “**Field Background Visibility**” value to **2**

“**Sparks**” are the eye candy which makes texture masks shine at the moment of its intersection. Let’s set it’s visibility as well:

* Set “**Field Sparks Visibility**” value to **3**

“**Inner Mask**” will flash first at the point of impact and will fade inwards by the speed of the “**Decay**” parameter controlled from the Force Field script. “**Offset**” specifies the size of the original mask where higher values will make the mask appear smaller due to POW function.

* Set “**Inner Mask Offset**” value to **8**
* Set “**Inner Mask Feather**” value to **8**

![](/files/-MAuHcJfvOZHzkXCW_WT)

“**Feather**” controls how smooth the mask should be drawn. Let us set some values to get the hang of it before diving into much of the technical details. The additional “**Outer Mask**” will reveal at the impact point spreading outwards and forming a “blast wave” effect:

* Set “**Outer Mask Offset**” value to **4**
* Set “**Outer Mask Feather**” value to **4**

### **Triggering the shield**

Last chapter concluded the shield set up and it is about time to wreck the havoc on the field. The Force Field controller you have attached earlier will handle such task of assuring the shield reacts accordingly to the damage dealt.

To simplify things, you will use a **SimlpeGun.Cs** that simulates the projectile cast from camera’s screen point beneath your mouse cursor.

* Attach the **SimpleGun.Cs** script to the camera. You will also find it located under the **Assets/FORGE3D/Force Field/Examples/Scripts** folder.

![](/files/-MAuHrG5-BbsUbvPeRNA)

### **Blast it!**

We went through the process of a shield assembly from scratch, and now everything is ready to launch into the game mode and trigger the shield.

* Hit **Play** within the editor and click and hold the **Left Mouse Button** on top of the sphere.

![](/files/-MAuHze5NkyZJTaHiVfv)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.forge3d.com/force-field/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
