# Verlet Spring

{% hint style="success" %}

#### Like what your seeing?

Support us as a [GitHub Sponsor](/old-kb/where-to-buy/become-a-sponsor.md) and get instant access to all our assets, exclusive tools and assets, escalated support and issue tracking and our gratitude.\
\
These articles are made possible by our [GitHub Sponsors](/old-kb/where-to-buy/become-a-sponsor.md) ... become a sponsor today!
{% endhint %}

## Introduction

![](/files/VLLnHYFQdKHq8B9GgE2I)

The Verlet Spring component manages hierarchies of transforms integrating Newtonian movement formulas according to the settings applied to each hierarchy.

In simpler terms it lets you describe how a chain of transforms should act physically speaking.

Each Verlet Spring component can manage any number of hierarchies, each component updates all of the hierarchies defined in it so you can use this concept to group systems together making it easier to turn them on and off.

For example you would add a Verlet Spring component to a character and then create hierarchies for that characters required parts. Then when that character is disabled its Verlet calculations are also disabled.

## Fields and Attributes

### Transform Hierarchies

```csharp
public List<VerletHierarchy> transformHierarchies;
```

The list of [hierarches ](/old-kb/toolkit-for-physics/physkit/objects/verlet-hierarchy.md)managed by the spring

You can manually add hierarchies by first constructing a hierarchy and adding it to the list

```csharp
var nTree = new VerletHierarchy
{
    root = rootTransform,
    nodes = new List<VerletParticle>(),
    ignoreList = new List<Transform>(),
    settings = new VerletHierarchySettingsReference(new VerletHierarchSettings())
};
//Add any transforms you want to exclude ... 
//all children of that tranform will also be excluded
nTree.ignoreList.Add(ignoreThisOne);
//This populates the nTree.nodes
nTree.RegisterNodes();

spring.transformHierarchies.Add(nTree);
```

## Methods

### Add Force

You can add additional forces to hierarchies to simulate effects like explosions, wind, etc. To add a force you can use

```csharp
spring.AddForce(Vector3 force);
```

This will add the force evenly to all hierarchies and nodes with in each hierarchy and is useful for global effects like gravity, wind or buoyancy

```csharp
spring.AddForceAtPosition(float forceMagnitude, Vector3 position);
```

This will apply a positional force and is more useful for effects like explosions.

{% hint style="info" %}
These methods are just shortcuts to effect all Hierarchies within the spring, you can applies these to specific hierarchies if you like. See [Verlet Hierarchy](/old-kb/toolkit-for-physics/physkit/objects/verlet-hierarchy.md) for more information
{% endhint %}


---

# 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://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/verlet-spring.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.
