# Create your own springs (extend the asset)

The toolkit allows advanced users to extend its functionality by creating custom SpringComponents tailored to their specific needs. If the existing SpringComponents don't meet your requirements, you can create your own by inheriting from the SpringComponent class.

**To create your own SpringComponent, follow these steps:**

1. **Create a new script:** Start by creating a new script that inherits from SpringComponent. This will be the foundation of your custom component.
2. **Declare your Springs**: In your custom SpringComponent class, declare the Spring(s) that you will use in the component. For example, you might declare a SpringFloat like this: public SpringFloat mySpringFloat;
3. **Register Springs:** Implement the RegisterSprings method and call RegisterSpring(spring) for each spring you declared. This ensures that the asset manages the lifecycle and update of every spring.
4. **Implement IsValidSpringComponent():** This method should return true or false depending on whether the component is properly set up. It's used to ensure that all necessary references are present and that all configurations are correct. If false is returned, the SpringComponent is automatically disabled.
5. **Set Initial Values:** In the SetInitialValues() method, set the initial values of your springs. This step is crucial, as otherwise, the springs will start at 0. You can use any logic to handle the initial values here. You can also make use of hasCustomInitialValues and hasCustomTarget that are part of SpringComponent. These booleans are used in the toolkit included implementations and you may want to use them too to branch the logic and set some other custom value such a serialized field when true. This approach provides flexibility in initializing your springs, allowing you to adapt to different scenarios and requirements within your custom SpringComponent.
6. **Update Logic:** In the Update() method (or any other method you prefer), implement the logic to use your springs. This is where you'll update values based on the registered springs' current values and apply them to your game objects or components.

By following these steps, you can create custom SpringComponents that integrate seamlessly with the toolkit. This allows you to leverage its powerful spring functionality while tailoring it to your specific project requirements.

For a practical example, you can refer to the NewSpringComponentExample.cs class included in the toolkit, which demonstrates these steps in action and documents the process.


---

# 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://seasidestudios.gitbook.io/seaside-studios/springs-toolkit/create-your-own-springs-extend-the-asset.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.
