# Spring System

## Description

> In engineering and physics, a *Spring System* or *Spring Network* is a model of physics described as a \[graph]\(<https://en.wikipedia.org/wiki/Graph_(discrete_mathematics>) "Graph (discrete mathematics)") with a position at each vertex and a \[spring]\(<https://en.wikipedia.org/wiki/Spring_(device>) "Spring (device)") of given stiffness and length along each edge.

With *FP Motion*, the *Spring System* is the part of the asset that allows developers to **produce motion effects** like: [Lean](/fp-motion/components/motion-effects/lean.md), [Bob](/fp-motion/components/motion-effects/bob.md)...etc

The [Handle ](/fp-motion/components/untitled.md)class contains all the spring code; every component that uses the spring system holds an instance of this class, as it is the ‘bridge’ between it and the [Motion Manager](/fp-motion/components/motion-manager.md).

## How does it work?

In order for the *Spring System* to work its magic, it first needs to have an object designated as a target, in *FP Motion* we do this by **subscribing** that object to the [Motion Manager](/fp-motion/components/motion-manager.md) trough a component (usually on that same object).

Once you subscribe the object to the manager, the latter will create and return a [Handle ](/fp-motion/components/untitled.md)for it, which is the component in charge of **calculating the spring physics**.

Once the object gets a [Handle](/fp-motion/components/untitled.md) value, the [Motion Manager](/fp-motion/components/motion-manager.md) having now registered and created a spring system for it will update the object’s physics every frame.

The system works in the following way:&#x20;

1\. Take a force.&#x20;

2\. Calculate the effect that force produces on an object.&#x20;

3\. Changes the object's state (Position, rotation and scale) to match.

The resulting changes in position, rotation and scale are something we calculate using [Hooke's Law](https://en.wikipedia.org/wiki/Hooke%27s_law), and thus allow you to have access to a couple of parameters, making each force **interesting and unique**, while keeping the precision that some games need.


---

# 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/spring-system.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.
