Skip to content
yenmoc edited this page Dec 16, 2022 · 1 revision

Spring system moves according to simple harmonic motion. If you hold a small coiled metal spring in your hand, it will remain at some rest length. If you try to compress the spring, it will apply a force trying to grow back to its rest length. If you stretch the spring, it will apply a force trying to shrink back to its rest length. We call this rest length, the equilibrium position of the spring. Unlike a real world coiled spring, our simple harmonic motion spring will have no drag, friction or other complex forces on it. It only has the push and pull due to fighting compression or extension.

Using spring in the game will increase your game experience. Take a look at the example below to understand better

private SpringPosition2DComponent springPosition;

springPosition.SpringTo(new Vector2(5f, 0));

private SpringPosition2DComponent springPosition;

springPosition.Nudge(new Vector2(50f, 0f));

In addition, you can also use Vector2Nudger or Vector3Nudger to automatically handle the Nudge

Clone this wiki locally