# Motion Effects

## Description

*Motion Effects* are movements, or motions that work procedurally with the use of *FP Motion's* spring system.

## How do they work?

A motion effect is a component that subscribes its game-object to the [Motion Manager](https://unfinishedstudios1.gitbook.io/fp-motion/components/motion-manager) and then uses the handle received to apply some forces; basically, all the motion effects are different, and we built them to showcase how the spring system works, and provide a **robust** set of components to help develop first-person-shooter games.

What they all have in common is that they all share a parent, the *Motion Behavior*; What this component provides is a way to **turn off** the effects with a press of a button.

{% hint style="info" %}
In version 2.0, the behavior parent class will see a lot of changes, and serve as a central hub to all motion scripts.
{% endhint %}

We made every effect in the asset for **both** camera and weapons, and thus the functionality works on both in the same manner, it only becomes different based on the [State Data](https://unfinishedstudios1.gitbook.io/fp-motion/data/state-data) used, which comes from the [State Handler](https://unfinishedstudios1.gitbook.io/fp-motion/components/state-handler).

The *Motion Effects* that you can find in the asset are:

* **Offset.** Moves the object to the position and rotation specified in the current state's data.
* **Bob, Roll & Strafe.** Position and rotate the object based on the player's movement, making the movement appear more realistic.
* **Breath.** Adds a breathing effect to the object, trying to imitate an idle animation.
* **Fall & Land.** Imitate a falling and landing animation by pushing the object backwards while falling, and pressing it down when landing.
* **Lean.** Allow the object to follow the player's lean input, and move to the side, making the player lean.
* **Sway.** Rotates the object based on the player's mouse input, making it seem like it lags.
* **Shooting.** Makes the object react to the player's shooting input by recoiling.
* **Animation Addition.** Follows another object's animation, but allows for tweaking how smooth/sharp it is.

{% hint style="info" %}
These effects are undergoing a massive revamp and will become a lot more polished, and better looking in version 2.0.
{% endhint %}

## Usage

Using *Motion Effects* is simple, you can just add the components that you need in your game to the game-object that needs them, and that will work!

That said, sometimes the object requiring these effects already has something driving its position or rotation; to fix this, we recommend that the developer make a **parent** for the object, and add the effects there.

Here's what the parenting looks like for the camera's effects:

<-> Effects <-----> Camera

## **Tweaking existing effects**

Changing the result a motion effect produces is a process different for each one of them, as they don't have the same forces being applied, and some don't even change the same things; Some effects change the position of objects, while some change the rotation, others may even change both.

What all motion effects have in-common though, is that they have properties dedicated to the springs themselves in the form of [Spring Data](https://unfinishedstudios1.gitbook.io/fp-motion/data/spring-data), these allow developers to make the spring for that effect **stiffer or smoother**, to cap the **maximum movement**, and other things.


---

# 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://unfinishedstudios1.gitbook.io/fp-motion/components/motion-effects.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.
