Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

PhysicsMath.SpringDamper

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static float SpringDamper(float frequency, float damping, float translation, float speed, float deltaTime);

Parameters

Parameter Description
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

float The new calculated spring speed.

Description

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;"