Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SpringDamper(float, float, float, float, float)

Calculate a one-dimensional mass-spring-damper simulation which drives towards a zero translation. You can then compute the new position using: "translation += newSpeed * deltaTime;"
Read time 1 minuteLast updated 10 days ago

Definition

  • Type: Method
  • Namespace: Unity.U2D.Physics
  • Assembly: UnityEngine.PhysicsCore2DModule
public static float SpringDamper(float frequency, float damping, float translation, float speed, float deltaTime)

Parameters

frequency

The frequency of the spring, in cycles per second.

damping

The damping of the spring. Must be >= zero.

translation

The current translation of the spring.

speed

The current speed of the spring.

deltaTime

The time over which to simulate the spring.

Returns

Type

Description

floatThe new calculated spring speed.