Skip to content

KimYC1223/DampingSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

DampingSystem

Unity License

Second-Order Damping Animation Library for Unity

Youtube video Giving Personality to Procedural Animations using Math inspired Unity package.

ํ•˜๋‹จ์— ํ•œ๊ตญ์–ด ๋ฒˆ์—ญ์ด ์žˆ์Šต๋‹ˆ๋‹ค.


๐Ÿ“‹ Table of Contents

  1. ๐ŸŽฏ Project Introduction
  2. โœจ Key Features
  3. ๐Ÿ”ง Installation
  4. ๐Ÿš€ Quick Start
  5. ๐Ÿ“– Detailed Usage
  6. ๐Ÿงฎ Mathematical Principles
  7. ๐ŸŽฎ Supported Types
  8. ๐Ÿ“Š Performance Characteristics
  9. ๐Ÿ”— References
  10. ๐Ÿ“ž Contact

๐ŸŽฏ Project Introduction

DampingSystem is a second-order system based damping library for creating natural and smooth animations in Unity. It simulates spring-damper system motion using physically accurate mathematical models.

๐ŸŽฅ WebGL Demo

To help you understand the project, I have prepared a WebGL demo!


โœจ Key Features

  • ๐Ÿ”ฌ Mathematical Accuracy: Physically accurate implementation based on second-order differential equations
  • ๐ŸŽฏ Multiple Type Support: Full support for float, float2/3, Vector2/3/4
  • ๐Ÿ”ง Ease of Use: Easy setup with intuitive parameters
  • ๐Ÿ“š Complete Documentation: Fully documented in both Korean and English

๐Ÿ”ง Installation

Download the latest released Unity Package or download this repository.

Requirements

  • Unity: 2022.3.20f1 or higher

๐Ÿš€ Quick Start

Basic Usage

using DampingSystem;

public class PlayerController : MonoBehaviour
{
    private DampingSystemVector3 positionDamper;
    
    void Start()
    {
        // Initialize damping system
        positionDamper = new DampingSystemVector3(
            frequency: 2.0f,        // Natural frequency
            dampingRatio: 1.0f,     // Damping ratio (1.0 = critical damping)
            initialResponse: 0.0f,  // Initial response
            initialCondition: transform.position
        );
    }
    
    void Update()
    {
        // Smooth movement to target position
        Vector3 targetPosition = GetTargetPosition();
        Vector3 smoothPosition = positionDamper.Calculate(targetPosition);
        transform.position = smoothPosition;
    }
}

๐Ÿ“– Detailed Usage

Parameter Description

Parameter Description Recommended Values
frequency Natural frequency (Hz)
Higher values = faster response
1.0 ~ 5.0
dampingRatio Damping ratio
1.0 = critical, >1.0 = overdamped, <1.0 = underdamped
0.7 ~ 1.2
initialResponse Initial response
Controls anticipation effect
0.0 ~ 0.5
initialCondition Initial condition
Starting state value
Current value

Behavior by Damping Ratio

// Underdamped - oscillates to convergence
var bouncyDamper = new DampingSystemFloat(2.0f, 0.5f, 0.0f, 0.0f);

// Critically Damped - fastest convergence
var criticalDamper = new DampingSystemFloat(2.0f, 1.0f, 0.0f, 0.0f);

// Overdamped - slow convergence, no overshoot
var slowDamper = new DampingSystemFloat(2.0f, 2.0f, 0.0f, 0.0f);

Custom Time Step Usage

void FixedUpdate()
{
    // Using fixed time step
    float customDeltaTime = Time.fixedDeltaTime;
    Vector3 result = damper.Calculate(target, customDeltaTime);
}

๐Ÿงฎ Mathematical Principles

Second-Order System Differential Equation

DampingSystem is based on the following second-order differential equation:

รฟ + 2ฮถฯ‰แบ + ฯ‰ยฒy = ฯ‰ยฒx + 2ฮถฯ‰rแบ‹

Where:

  • ฯ‰ = Natural angular frequency (ฯ‰ = 2ฯ€f)
  • ฮถ = Damping ratio
  • r = Initial response coefficient
  • x = Input signal
  • y = Output signal

For detailed information, refer to this video!


๐ŸŽฎ Supported Types

The DampingSystem package provides specialized implementations for different data types, each optimized for their specific use cases:

Scalar Types

// Float damping - perfect for UI animations, health bars, etc.
var floatDamper = new DampingSystemFloat(2.0f, 1.0f, 0.0f, 0.0f);
float smoothValue = floatDamper.Calculate(targetValue);

Unity.Mathematics Types

// Float2 damping - optimized for 2D coordinates using Unity.Mathematics
var float2Damper = new DampingSystemFloat2(2.0f, 1.0f, 0.0f, new float2(0, 0));
float2 smoothPos2D = float2Damper.Calculate(targetPos2D);

// Float3 damping - optimized for 3D coordinates using Unity.Mathematics
var float3Damper = new DampingSystemFloat3(2.0f, 1.0f, 0.0f, new float3(0, 0, 0));
float3 smoothPos3D = float3Damper.Calculate(targetPos3D);

Vector Types

// 2D position damping - ideal for 2D games and UI elements
var vec2Damper = new DampingSystemVector2(1.5f, 0.8f, 0.0f, Vector2.zero);

// 3D position damping - for smooth character/camera movement
var vec3Damper = new DampingSystemVector3(2.0f, 1.0f, 0.1f, Vector3.zero);

// 4D vector damping - useful for color transitions, RGBA values
var vec4Damper = new DampingSystemVector4(3.0f, 1.2f, 0.0f, Vector4.one);

Implementation Structure

All damping systems inherit from the abstract base class DampingSystem<T> located in:

Assets/DampingSystem/Scripts/Abstract/DampingSystem.cs

Each type-specific implementation can be found in:

  • DampingSystemFloat.cs
  • DampingSystemFloat2.cs (Unity.Mathematics)
  • DampingSystemFloat3.cs (Unity.Mathematics)
  • DampingSystemVector2.cs
  • DampingSystemVector3.cs
  • DampingSystemVector4.cs

๐Ÿ“Š Performance Characteristics

Benchmark Results

Type Operation Time (ns) Memory Usage
Float ~15 64 bytes
Float2 ~25 72 bytes
Float3 ~35 88 bytes
Vector2 ~30 80 bytes
Vector3 ~45 96 bytes
Vector4 ~60 112 bytes

๐ŸŽฏ Comparison with Other Libraries

๐Ÿ”ท DOTween

DampingSystem is a Unity library that simulates second-order differential equations to create smooth, natural damping animations. You can tweak the motion using physical parameters like frequency and dampingRatio, and since itโ€™s built on a struct-based design, it runs with zero memory allocations and delivers lightning-fast performanceโ€”around 15โ€“60ns per update.

DOTween, on the other hand, is an interpolation-based tweening library. It lets you control animation precisely over a set duration using easing functions, making it easy to create a wide variety of animation effects.

The key difference lies in their approach. DampingSystem uses a physically accurate spring-damper model, so it responds naturally even when the target value changes in real time. This makes it great for things like camera tracking or character movement. DOTween, in contrast, follows predefined paths and timings, making it ideal for UI animations, cutscenes, or anything where precise timing is essential.

In terms of raw performance, DampingSystem can be about 2โ€“4ร— faster and more memory-efficient. But DOTween shines when it comes to rich features and its sequencing system, which gives you a lot of flexibility for complex animations.

๐Ÿ“Š Differences

Items DampingSystem DOTween
Mathematical Basis Second-Order Differential Equation-Based Physics Simulation Interpolation-Based Animation
Dependencies Uses only Unity built-in functions External Libraries
Memory Allocation Zero-Allocation (struct-based) Requires Object Pooling
Performance 15-60ns (depending on type) 100-200ns
Animation Style Physically Natural Movements Various Easing Functions
Control Method Physics Parameters (frequency, damping) Time-Based (duration, delay)

When to Choose DampingSystem

โœ… When you need natural physical movement

Camera tracking, character movement, smooth UI element response

โœ… When you need real-time responsive animation

When target values constantly change (mouse tracking, player following)

โœ… When you want to control physical properties

damping ratio, frequency, etc.

When to Choose DOTween

โœ… When you need precise timing control

Cutscenes, sequence animations, and timing-critical productions

โœ… When you need various easing effects

Special effects such as Ease In/Out, Bounce, and Elastic

โœ… When you need complex animation chains

Sequential animation, callbacks, and event systems

โœ… When you need specialized features for UI animation

Various property animations such as size, rotation, color change, etc.

๐Ÿ”— References


๐Ÿ“ž Contact

Developer: KimYC1223
Email: kau_esc@naver.com
GitHub: @KimYC1223

โญ If this project was helpful, please give it a star! โญ

Made with โค๏ธ by KimYC1223




DampingSystem

Unity License

Unity์šฉ 2์ฐจ ์‹œ์Šคํ…œ ๊ธฐ๋ฐ˜ ๊ฐ์‡  ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

Youtube ์˜์ƒ Giving Personality to Procedural Animations using Math์„ ๋ณด๊ณ  ์˜๊ฐ์„ ๋ฐ›์•„ ๋งŒ๋“  Unity package์ž…๋‹ˆ๋‹ค.

There is a English translation at the top.


๐Ÿ“‹ ๋ชฉ์ฐจ

  1. ๐ŸŽฏ ํ”„๋กœ์ ํŠธ ์†Œ๊ฐœ
  2. โœจ ์ฃผ์š” ํŠน์ง•
  3. ๐Ÿ”ง ์„ค์น˜ ๋ฐฉ๋ฒ•
  4. ๐Ÿš€ ๋น ๋ฅธ ์‹œ์ž‘
  5. ๐Ÿ“– ์ƒ์„ธ ์‚ฌ์šฉ๋ฒ•
  6. ๐Ÿงฎ ์ˆ˜ํ•™์  ์›๋ฆฌ
  7. ๐ŸŽฎ ์ง€์› ํƒ€์ž…
  8. ๐Ÿ“Š ์„ฑ๋Šฅ ํŠน์„ฑ
  9. ๐Ÿ”— ์ฐธ๊ณ ์ž๋ฃŒ
  10. ๐Ÿ“ž ์—ฐ๋ฝ์ฒ˜

๐ŸŽฏ ํ”„๋กœ์ ํŠธ ์†Œ๊ฐœ

DampingSystem์€ Unity์—์„œ ์ž์—ฐ์Šค๋Ÿฝ๊ณ  ๋ถ€๋“œ๋Ÿฌ์šด ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•œ 2์ฐจ ์‹œ์Šคํ…œ ๊ธฐ๋ฐ˜ ๊ฐ์‡  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค. ๋ฌผ๋ฆฌ์ ์œผ๋กœ ์ •ํ™•ํ•œ ์ˆ˜ํ•™ ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ์Šคํ”„๋ง-๋Œํผ ์‹œ์Šคํ…œ์˜ ์›€์ง์ž„์„ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ํ•ฉ๋‹ˆ๋‹ค.

๐ŸŽฅ WebGL๋ฐ๋ชจ

ํ”„๋กœ์ ํŠธ์˜ ์ดํ•ด๋ฅผ ๋•๊ธฐ ์œ„ํ•œ WebGL ๋ฐ๋ชจ๊ฐ€ ์ค€๋น„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค!


โœจ ์ฃผ์š” ํŠน์ง•

  • ๐Ÿ”ฌ ์ˆ˜ํ•™์  ์ •ํ™•์„ฑ: 2์ฐจ ๋ฏธ๋ถ„๋ฐฉ์ •์‹ ๊ธฐ๋ฐ˜์˜ ๋ฌผ๋ฆฌ์ ์œผ๋กœ ์ •ํ™•ํ•œ ๊ตฌํ˜„
  • ๐ŸŽฏ ๋‹ค์–‘ํ•œ ํƒ€์ž… ์ง€์›: float, float2/3, Vector2/3/4 ์™„๋ฒฝ ์ง€์›
  • ๐Ÿ”ง ์‚ฌ์šฉ ํŽธ์˜์„ฑ: ์ง๊ด€์ ์ธ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์‰ฌ์šด ์„ค์ •
  • ๐Ÿ“š ์™„์ „ํ•œ ๋ฌธ์„œํ™”: ํ•œ๊ตญ์–ด/์˜์–ด ์ด์ค‘ ๋ฌธ์„œํ™”

๐Ÿ”ง ์„ค์น˜ ๋ฐฉ๋ฒ•

์ตœ์‹ ์˜ release๋œ Unity Package๋ฅผ ๋‹ค์šด๋กœ๋“œ ํ•˜๊ฑฐ๋‚˜, ์ด repo๋ฅผ ๋‹ค์šด๋ฐ›์œผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

์š”๊ตฌ์‚ฌํ•ญ

  • Unity: 2022.3.20f1 ์ด์ƒ

๐Ÿš€ ๋น ๋ฅธ ์‹œ์ž‘

๊ธฐ๋ณธ ์‚ฌ์šฉ๋ฒ•

using DampingSystem;

public class PlayerController : MonoBehaviour
{
    private DampingSystemVector3 positionDamper;
    
    void Start()
    {
        // ๊ฐ์‡  ์‹œ์Šคํ…œ ์ดˆ๊ธฐํ™”
        positionDamper = new DampingSystemVector3(
            frequency: 2.0f,        // ์ž์—ฐ ์ง„๋™์ˆ˜
            dampingRatio: 1.0f,     // ๊ฐ์‡ ๋น„ (1.0 = ์ž„๊ณ„๊ฐ์‡ )
            initialResponse: 0.0f,  // ์ดˆ๊ธฐ ์‘๋‹ต
            initialCondition: transform.position
        );
    }
    
    void Update()
    {
        // ๋ชฉํ‘œ ์œ„์น˜๋กœ ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ์ด๋™
        Vector3 targetPosition = GetTargetPosition();
        Vector3 smoothPosition = positionDamper.Calculate(targetPosition);
        transform.position = smoothPosition;
    }
}

๐Ÿ“– ์ƒ์„ธ ์‚ฌ์šฉ๋ฒ•

๋งค๊ฐœ๋ณ€์ˆ˜ ์„ค๋ช…

๋งค๊ฐœ๋ณ€์ˆ˜ ์„ค๋ช… ๊ถŒ์žฅ๊ฐ’
frequency ์ž์—ฐ ์ง„๋™์ˆ˜ (Hz)
๊ฐ’์ด ํด์ˆ˜๋ก ๋น ๋ฅธ ๋ฐ˜์‘
1.0 ~ 5.0
dampingRatio ๊ฐ์‡ ๋น„
1.0 = ์ž„๊ณ„๊ฐ์‡ , >1.0 = ๊ณผ๊ฐ์‡ , <1.0 = ๋ถ€์กฑ๊ฐ์‡ 
0.7 ~ 1.2
initialResponse ์ดˆ๊ธฐ ์‘๋‹ต
anticipation ํšจ๊ณผ ์กฐ์ ˆ
0.0 ~ 0.5
initialCondition ์ดˆ๊ธฐ ์กฐ๊ฑด
์‹œ์ž‘ ์ƒํƒœ๊ฐ’
ํ˜„์žฌ๊ฐ’

๊ฐ์‡ ๋น„์— ๋”ฐ๋ฅธ ๋™์ž‘ ํŠน์„ฑ

// ๋ถ€์กฑ๊ฐ์‡  (Underdamped) - ์ง„๋™ํ•˜๋ฉฐ ์ˆ˜๋ ด
var bouncyDamper = new DampingSystemFloat(2.0f, 0.5f, 0.0f, 0.0f);

// ์ž„๊ณ„๊ฐ์‡  (Critically Damped) - ๊ฐ€์žฅ ๋น ๋ฅธ ์ˆ˜๋ ด
var criticalDamper = new DampingSystemFloat(2.0f, 1.0f, 0.0f, 0.0f);

// ๊ณผ๊ฐ์‡  (Overdamped) - ๋А๋ฆฐ ์ˆ˜๋ ด, ์˜ค๋ฒ„์ŠˆํŠธ ์—†์Œ
var slowDamper = new DampingSystemFloat(2.0f, 2.0f, 0.0f, 0.0f);

์ปค์Šคํ…€ ์‹œ๊ฐ„ ๊ฐ„๊ฒฉ ์‚ฌ์šฉ

void FixedUpdate()
{
    // ๊ณ ์ • ์‹œ๊ฐ„ ๊ฐ„๊ฒฉ ์‚ฌ์šฉ
    float customDeltaTime = Time.fixedDeltaTime;
    Vector3 result = damper.Calculate(target, customDeltaTime);
}

๐Ÿงฎ ์ˆ˜ํ•™์  ์›๋ฆฌ

2์ฐจ ์‹œ์Šคํ…œ ๋ฏธ๋ถ„๋ฐฉ์ •์‹

DampingSystem์€ ๋‹ค์Œ 2์ฐจ ๋ฏธ๋ถ„๋ฐฉ์ •์‹์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค:

รฟ + 2ฮถฯ‰แบ + ฯ‰ยฒy = ฯ‰ยฒx + 2ฮถฯ‰rแบ‹

์—ฌ๊ธฐ์„œ:

  • ฯ‰ = ์ž์—ฐ ๊ฐ์ฃผํŒŒ์ˆ˜ (ฯ‰ = 2ฯ€f)
  • ฮถ = ๊ฐ์‡ ๋น„
  • r = ์ดˆ๊ธฐ ์‘๋‹ต ๊ณ„์ˆ˜
  • x = ์ž…๋ ฅ ์‹ ํ˜ธ
  • y = ์ถœ๋ ฅ ์‹ ํ˜ธ

์ž์„ธํ•œ ๋‚ด์šฉ์€ ์ด ์˜์ƒ์„ ์ฐธ๊ณ ํ•˜์„ธ์š”!


๐ŸŽฎ ์ง€์› ํƒ€์ž…

DampingSystem ํŒจํ‚ค์ง€๋Š” ๊ฐ๊ฐ์˜ ํŠน์ • ์‚ฌ์šฉ ์‚ฌ๋ก€์— ์ตœ์ ํ™”๋œ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ํƒ€์ž…๋ณ„ ํŠนํ™” ๊ตฌํ˜„์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค:

์Šค์นผ๋ผ ํƒ€์ž…

// Float ๊ฐ์‡  - UI ์• ๋‹ˆ๋ฉ”์ด์…˜, ์ฒด๋ ฅ๋ฐ” ๋“ฑ์— ์™„๋ฒฝ
var floatDamper = new DampingSystemFloat(2.0f, 1.0f, 0.0f, 0.0f);
float smoothValue = floatDamper.Calculate(targetValue);

Unity.Mathematics ํƒ€์ž…

// Float2 ๊ฐ์‡  - Unity.Mathematics๋ฅผ ์‚ฌ์šฉํ•œ ์ตœ์ ํ™”๋œ 2D ์ขŒํ‘œ
var float2Damper = new DampingSystemFloat2(2.0f, 1.0f, 0.0f, new float2(0, 0));
float2 smoothPos2D = float2Damper.Calculate(targetPos2D);

// Float3 ๊ฐ์‡  - Unity.Mathematics๋ฅผ ์‚ฌ์šฉํ•œ ์ตœ์ ํ™”๋œ 3D ์ขŒํ‘œ
var float3Damper = new DampingSystemFloat3(2.0f, 1.0f, 0.0f, new float3(0, 0, 0));
float3 smoothPos3D = float3Damper.Calculate(targetPos3D);

๋ฒกํ„ฐ ํƒ€์ž…

// 2D ์œ„์น˜ ๊ฐ์‡  - 2D ๊ฒŒ์ž„๊ณผ UI ์š”์†Œ์— ์ด์ƒ์ 
var vec2Damper = new DampingSystemVector2(1.5f, 0.8f, 0.0f, Vector2.zero);

// 3D ์œ„์น˜ ๊ฐ์‡  - ๋ถ€๋“œ๋Ÿฌ์šด ์บ๋ฆญํ„ฐ/์นด๋ฉ”๋ผ ์›€์ง์ž„์šฉ
var vec3Damper = new DampingSystemVector3(2.0f, 1.0f, 0.1f, Vector3.zero);

// 4D ๋ฒกํ„ฐ ๊ฐ์‡  - ์ƒ‰์ƒ ์ „ํ™˜, RGBA ๊ฐ’์— ์œ ์šฉ
var vec4Damper = new DampingSystemVector4(3.0f, 1.2f, 0.0f, Vector4.one);

๊ตฌํ˜„ ๊ตฌ์กฐ

๋ชจ๋“  ๊ฐ์‡  ์‹œ์Šคํ…œ์€ ๋‹ค์Œ ์œ„์น˜์˜ ์ถ”์ƒ ๊ธฐ๋ณธ ํด๋ž˜์Šค DampingSystem<T>๋ฅผ ์ƒ์†๋ฐ›์Šต๋‹ˆ๋‹ค:

Assets/DampingSystem/Scripts/Abstract/DampingSystem.cs

๊ฐ ํƒ€์ž…๋ณ„ ๊ตฌํ˜„์€ ๋‹ค์Œ์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

  • DampingSystemFloat.cs
  • DampingSystemFloat2.cs (Unity.Mathematics)
  • DampingSystemFloat3.cs (Unity.Mathematics)
  • DampingSystemVector2.cs
  • DampingSystemVector3.cs
  • DampingSystemVector4.cs

๐Ÿ“Š ์„ฑ๋Šฅ ํŠน์„ฑ

๋ฒค์น˜๋งˆํฌ ๊ฒฐ๊ณผ

ํƒ€์ž… ์—ฐ์‚ฐ ์‹œ๊ฐ„ (ns) ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰
Float ~15 64 bytes
Float2 ~25 72 bytes
Float3 ~35 88 bytes
Vector2 ~30 80 bytes
Vector3 ~45 96 bytes
Vector4 ~60 112 bytes

๐ŸŽฏ ๋‹ค๋ฅธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ ๋น„๊ต

๐Ÿ”ท DOTween

DampingSystem์€ 2์ฐจ ๋ฏธ๋ถ„๋ฐฉ์ •์‹์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฌผ๋ฆฌ ์‹œ๋ฎฌ๋ ˆ์ด์…˜์„ ๋Œ๋ ค์„œ, ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๊ฐ์‡ ๋˜๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“ค์–ด์ฃผ๋Š” Unity ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค. frequency๋‚˜ dampingRatio ๊ฐ™์€ ๋ฌผ๋ฆฌ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ์›€์ง์ž„์„ ์กฐ์ ˆํ•˜๊ณ , struct ๊ธฐ๋ฐ˜์ด๋ผ ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น ์—†์ด 15~60ns ์ •๋„์˜ ๋น ๋ฅธ ์„ฑ๋Šฅ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

๋ฐ˜๋ฉด DOTween์€ ๋ณด๊ฐ„(Interpolation) ๋ฐฉ์‹์˜ ํŠธ์œ„๋‹ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ, duration๊ณผ ์ด์ง• ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•ด ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹œ๊ฐ„์„ ์ •ํ™•ํžˆ ๋งž์ถ”๊ณ  ๋‹ค์–‘ํ•œ ์—ฐ์ถœ ํšจ๊ณผ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‘˜์˜ ํ•ต์‹ฌ ์ฐจ์ด๋Š” ์ ‘๊ทผ ๋ฐฉ์‹์— ์žˆ์Šต๋‹ˆ๋‹ค. DampingSystem์€ ๋ฌผ๋ฆฌ์ ์œผ๋กœ ์ •ํ™•ํ•œ ์Šคํ”„๋ง-๋Œํผ ๋ชจ๋ธ์„ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ๋ชฉํ‘œ๊ฐ’์ด ์‹ค์‹œ๊ฐ„์œผ๋กœ ๋ฐ”๋€Œ์–ด๋„ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋”ฐ๋ผ๊ฐ€๋Š” ๋ฐ ๊ฐ•์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์นด๋ฉ”๋ผ ์ถ”์ ์ด๋‚˜ ์บ๋ฆญํ„ฐ ์ด๋™ ๊ฐ™์€ ์ƒํ™ฉ์— ํŠนํžˆ ์ž˜ ์–ด์šธ๋ฆฝ๋‹ˆ๋‹ค. ๋ฐ˜๋Œ€๋กœ DOTween์€ ๋ฏธ๋ฆฌ ์ •ํ•ด๋‘” ๊ฒฝ๋กœ๋‚˜ ์‹œ๊ฐ„์„ ๊ทธ๋Œ€๋กœ ๋”ฐ๋ผ๊ฐ€์„œ, UI ์• ๋‹ˆ๋ฉ”์ด์…˜์ด๋‚˜ ์ปท์‹ ์ฒ˜๋Ÿผ ์ •ํ™•ํ•œ ํƒ€์ด๋ฐ์ด ์ค‘์š”ํ•œ ์—ฐ์ถœ์— ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค.

์„ฑ๋Šฅ๋งŒ ๋ณด๋ฉด DampingSystem์ด ์•ฝ 2~4๋ฐฐ ๋น ๋ฅด๊ณ  ๋ฉ”๋ชจ๋ฆฌ ํšจ์œจ๋„ ์ข‹์ง€๋งŒ, DOTween์€ ๋” ๋งŽ์€ ๊ธฐ๋Šฅ๊ณผ ์‹œํ€€์Šค ์‹œ์Šคํ…œ์„ ๊ฐ–์ถ”๊ณ  ์žˆ์–ด ๋‹ค์–‘ํ•œ ์—ฐ์ถœ ์ž‘์—…์— ์œ ๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ“Š ํ•ต์‹ฌ ์ฐจ์ด์ 

ํ•ญ๋ชฉ DampingSystem DOTween
์ˆ˜ํ•™์  ๊ธฐ๋ฐ˜ 2์ฐจ ๋ฏธ๋ถ„๋ฐฉ์ •์‹ ๊ธฐ๋ฐ˜ ๋ฌผ๋ฆฌ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ๋ณด๊ฐ„ ๊ธฐ๋ฐ˜ ์• ๋‹ˆ๋ฉ”์ด์…˜
์˜์กด์„ฑ Unity ๋‚ด์žฅ ๊ธฐ๋Šฅ๋งŒ ์‚ฌ์šฉ ์™ธ๋ถ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น ์ œ๋กœ ํ• ๋‹น (struct ๊ธฐ๋ฐ˜) ๊ฐ์ฒด ํ’€๋ง ํ•„์š”
์„ฑ๋Šฅ 15-60ns (ํƒ€์ž…๋ณ„) 100-200ns
์• ๋‹ˆ๋ฉ”์ด์…˜ ์Šคํƒ€์ผ ๋ฌผ๋ฆฌ์ ์œผ๋กœ ์ž์—ฐ์Šค๋Ÿฌ์šด ์›€์ง์ž„ ๋‹ค์–‘ํ•œ ์ด์ง• ํ•จ์ˆ˜
์ œ์–ด ๋ฐฉ์‹ ๋ฌผ๋ฆฌ ๋งค๊ฐœ๋ณ€์ˆ˜ (frequency, damping) ์‹œ๊ฐ„ ๊ธฐ๋ฐ˜ (duration, delay)

DampingSystem์„ ์„ ํƒํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ

โœ… ์ž์—ฐ์Šค๋Ÿฌ์šด ๋ฌผ๋ฆฌ์  ์›€์ง์ž„์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ

์นด๋ฉ”๋ผ ์ถ”์ , ์บ๋ฆญํ„ฐ ์ด๋™, UI ์š”์†Œ์˜ ๋ถ€๋“œ๋Ÿฌ์šด ๋ฐ˜์‘

โœ… ์‹ค์‹œ๊ฐ„ ๋ฐ˜์‘ํ˜• ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ

๋ชฉํ‘œ๊ฐ’์ด ๊ณ„์† ๋ณ€ํ•˜๋Š” ์ƒํ™ฉ (๋งˆ์šฐ์Šค ์ถ”์ , ํ”Œ๋ ˆ์ด์–ด ๋”ฐ๋ผ๊ฐ€๊ธฐ)

โœ… ๋ฌผ๋ฆฌ์  ํŠน์„ฑ์„ ์กฐ์ ˆํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ

๊ฐ์‡ ๋น„, ์ง„๋™์ˆ˜ ๋“ฑ

DOTween์„ ์„ ํƒํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ

โœ… ์ •ํ™•ํ•œ ์‹œ๊ฐ„ ์ œ์–ด๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ

์ปท์‹ , ์‹œํ€€์Šค ์• ๋‹ˆ๋ฉ”์ด์…˜, ํƒ€์ด๋ฐ์ด ์ค‘์š”ํ•œ ์—ฐ์ถœ

โœ… ๋‹ค์–‘ํ•œ ์ด์ง• ํšจ๊ณผ๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ

Ease In/Out, Bounce, Elastic ๋“ฑ์˜ ํŠน์ˆ˜ ํšจ๊ณผ

โœ… ๋ณต์žกํ•œ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ฒด์ธ์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ

์ˆœ์ฐจ์  ์• ๋‹ˆ๋ฉ”์ด์…˜, ์ฝœ๋ฐฑ, ์ด๋ฒคํŠธ ์‹œ์Šคํ…œ

โœ… UI ์• ๋‹ˆ๋ฉ”์ด์…˜์— ํŠนํ™”๋œ ๊ธฐ๋Šฅ์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ

ํฌ๊ธฐ, ํšŒ์ „, ์ƒ‰์ƒ ๋ณ€๊ฒฝ ๋“ฑ์˜ ๋‹ค์–‘ํ•œ ํ”„๋กœํผํ‹ฐ ์• ๋‹ˆ๋ฉ”์ด์…˜

๐Ÿ”— ์ฐธ๊ณ ์ž๋ฃŒ


๐Ÿ“ž ์—ฐ๋ฝ์ฒ˜

๊ฐœ๋ฐœ์ž: KimYC1223
์ด๋ฉ”์ผ: kau_esc@naver.com
GitHub: @KimYC1223

โญ ์ด ํ”„๋กœ์ ํŠธ๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด Star๋ฅผ ๋ˆŒ๋Ÿฌ์ฃผ์„ธ์š”! โญ

Made with โค๏ธ by KimYC1223

About

Unity Simple Damping System Module

Resources

Stars

Watchers

Forks

Packages

No packages published