ํƒ€์ž„๋ผ์ธ๐ŸŽฌ 06 - Custom Playables๋กœ ์‹œ๊ฐ„ ๋‹ค๋ฃจ๊ธฐ (์ œ์ž‘ ๋ฆฌ๋ทฐ ๋ฐ ์ฝ”๋“œ๊ณต์œ )

ํƒ€์ž„๋ผ์ธ๐ŸŽฌ 06 - Custom Playables๋กœ ์‹œ๊ฐ„ ๋‹ค๋ฃจ๊ธฐ (์ œ์ž‘ ๋ฆฌ๋ทฐ ๋ฐ ์ฝ”๋“œ๊ณต์œ )

์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ฐ ํŠœํ† ๋ฆฌ์–ผ ์ œ์ž‘์— ์œ ์šฉํ•œ ์œ ๋‹ˆํ‹ฐ ํƒ€์ž„๋ผ์ธ์— ๋Œ€ํ•ด ์•Œ์•„๋ณธ๋‹ค. ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ํƒ€์ž„๋ผ์ธ์—์„œ ์‹œ๊ฐ„์„ ๋‹ค๋ฃจ๋Š” ๋ฒ•์— ๋Œ€ํ•ด ํ•„์ž๊ฐ€ ์‹ค์ œ ํ”„๋กœ์ ํŠธ์— ์‚ฌ์šฉํ•œ ์ฝ”๋“œ๋ฅผ ๋ณด๋ฉฐ ๋ฆฌ๋ทฐํ•œ๋‹ค.

Custom Playables๋กœ ์‹œ๊ฐ„์„ ๋‹ค๋ฃจ๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณธ๋‹ค. ๊ธฐ์กด ์œ ๋‹ˆํ‹ฐ์—์„œ ์‹œ๊ฐ„์„ ๋‹ค๋ฃจ๋ ค๋ฉด (๊ธฐ๋ณธ์ ์œผ๋กœ ์ถ”์ฒœํ•˜์ง€ ์•Š๋Š” ๋ฐฉ์‹์ด๊ธด ํ•˜์ง€๋งŒ) TimeScale์„ ๊ฑด๋“œ๋ฆฌ๊ฑฐ๋‚˜, ๋ณ„๋„์˜ ์‹œ์Šคํ…œ์„ ๋งŒ๋“ค์–ด ์‚ฌ์šฉํ•ด์•ผ๋งŒ ํ–ˆ๋‹ค.

ํƒ€์ž„๋ผ์ธ์€ ์œ ๋‹ˆํ‹ฐ์˜ TimeScale์„ ๊ฑด๋“œ๋ฆฌ์ง€ ์•Š๊ณ ๋„ ์•„์ฃผ ์‰ฝ๊ฒŒ ๋ณ„๋„์˜ ์‹œ๊ฐ„์„ ์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋„๋ก ์„ค๊ณ„๋˜์–ด ์žˆ๋‹ค. ์•„๋ž˜์˜ ๊ธ€์—์„œ๋Š” ์‹ค์ œ ํ”„๋กœ์ ํŠธ์— ์‚ฌ์šฉํ–ˆ๋˜ ์ฝ”๋“œ ์ค‘ โ€˜ํƒ€์ž„๋ผ์ธ์˜ ์‹œ๊ฐ„์„ ๊ฑด๋“œ๋ฆฌ๋Š” ์ฝ”๋“œ๋“คโ€™์— ๋Œ€ํ•ด ๋‹ค๋ฃฌ๋‹ค.

SlowMotion Track

์ฒ˜์Œ ํƒ€์ž„๋ผ์ธ ์ž‘์—…์—์„œ Custom Playables ์ œ์ž‘์„ ํ•ด์•ผ๊ฒ ๋‹ค๊ณ  ์ƒ๊ฐ์ด ๋“ค์—ˆ๋˜ ๋•Œ๋Š” โ€˜ํƒ€์ž„๋ผ์ธ์˜ ์‹œ๊ฐ„์„ ์ž์œ ๋กญ๊ฒŒ ๋‹ค๋ค„์•ผ ํ•˜๋Š” ๊ธฐ๋Šฅโ€™์„ ๊ฐœ๋ฐœํ•  ๋•Œ์˜€๋‹ค. ํ”„๋กœ์ ํŠธ์˜ ํŠน์„ฑ์ƒ ํƒ€์ž„๋ผ์ธ ์„œ์„œํžˆ ๋Š๋ ค์ง€๊ณ , ๋‹ค์‹œ ๋นจ๋ผ์ง€๊ณ , ์‹œ๊ฐ„์„ ๋›ฐ์–ด๋„˜๋Š” ๊ธฐ๋Šฅ์ด ํ•„์š”ํ–ˆ๋‹ค. Signal๋กœ ํ•˜๊ธฐ์—” ์‚ฌ์šฉํ•ด์•ผํ•˜๋Š” ๊ณณ์ด ๋งŽ์•˜๊ณ , ์ฝ”๋“œ๋กœ ํ•˜์ž๋‹ˆ ํƒ€์ž„๋ผ์ธ๊ณผ์˜ ํƒ€์ด๋ฐ์„ ๋งž์ถ”๊ฑฐ๋‚˜ ํ”„๋กœ๊ทธ๋ž˜๋จธ๊ฐ€ ์•„๋‹Œ ์‚ฌ๋žŒ์ด ๋‹ค๋ฃจ๊ธฐ๊ฐ€ ํž˜๋“ค์—ˆ๋‹ค. ๋”ฐ๋ผ์„œ Custom Playables๋กœ ๊ฐœ๋ฐœํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค.

โ›” ๋งŒ์•ฝ ํƒ€์ž„๋ผ์ธ์˜ ์‹œ๊ฐ„๋งŒ ๊ฐ„๋‹จํžˆ ์กฐ์ ˆํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด SlowMotion Track๋ณด๋‹ค๋Š” ์•„๋ž˜์˜ TimelineSpeed Track ์„ค๋ช…์„ ์ถ”์ฒœํ•œ๋‹ค. ํ•˜์ง€๋งŒ ํƒ€์ž„๋ผ์ธ์˜ ์‹œ๊ฐ„์— ์กฐ๊ฑด์„ ๊ฑธ์–ด ์กฐ์ ˆํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด SlowMotion Track์„ ์ฝ๋Š” ๊ฒƒ๋„ ๋„์›€์ด ๋  ๊ฒƒ์ด๋‹ค. (๐Ÿ‘‰์ด๋™ํ•˜๊ธฐ)

์ฐธ๊ณ  ํ”„๋กœ์ ํŠธ: Terrible Kingdom Demo

์œ ์‚ฌํ•œ ์˜ˆ์ œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ฐพ์•„๋ณด๋‹ˆ ์œ ๋‹ˆํ‹ฐ์—์„œ ์ œ๊ณตํ•˜๋Š” Terrible Kingdom์ด๋ผ๋Š” ์ œ๋ชฉ์˜ ๋ฐ๋ชจ ํ”„๋กœ์ ํŠธ๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

01

๐Ÿ‘‰ ์˜ˆ์ œ ์„ค๋ช… ๋งํฌ

๐Ÿ‘‰ ์˜ˆ์ œ ๋‹ค์šด๋กœ๋“œ ๋งํฌ

์ด ํ”„๋กœ์ ํŠธ์—๋Š” ๋‹ค์–‘ํ•œ ์ปค์Šคํ…€ ํ”Œ๋ ˆ์ด์–ด๋ธ” ํŠธ๋ž™๋“ค์ด ์žˆ๋‹ค. ๋ช‡ ๊ฐ€์ง€๋Š” ํ•ด๋‹น ํ”„๋กœ์ ํŠธ์˜ ๋งค๋‹ˆ์ €์™€ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•ด์•ผํ•˜๋Š” ํŠธ๋ž™๋“ค์ด๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์„ค๋ช… ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•˜๊ฑฐ๋‚˜ Demo๋ฅผ ๋‹ค์šด๋ฐ›์•„ ์ง์ ‘ ์‚ดํŽด๋ณด๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค.

  • AI Command Track
  • Dialogue Track
  • Light Track
  • SimpleClip
  • TMPTextSwitcher
  • Time Machine Track

์—ฌ๊ธฐ์„œ ํ•„์ž๊ฐ€ ์ฐธ๊ณ ํ•œ ํŠธ๋ž™์€ Time Machine Track์ด๋‹ค. ์ด๋ฆ„์„ ๋ณด๋ฉด ์•Œ๊ฒ ์ง€๋งŒ ํƒ€์ž„๋ผ์ธ์—์„œ ํŠน์ • ์‹œ๊ฐ„์œผ๋กœ ์ด๋™ํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค. ์—ฌ๊ธฐ์„œ โ€˜ํŠน์ • ์‹œ๊ฐ„์œผ๋กœ ์ด๋™ํ•˜๋Š” ๊ธฐ๋Šฅโ€™์„ ์ฐธ๊ณ ํ•˜์—ฌ ํŠธ๋ž™์„ ๋งŒ๋“ค์—ˆ๋‹ค.

๊ฐœ์กฐ

์ฐธ๊ณ  ํ”„๋กœ์ ํŠธ์—์„œ ์‚ฌ์šฉ๋œ Time Machine Track์„ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•˜๊ธฐ์—” ํ”„๋กœ์ ํŠธ์— ์“ฐ๋ ค๋ฉด ์ปค์Šคํ„ฐ๋งˆ์ด์ง• ํ•ด์•ผํ•˜๋Š” ๋ถ€๋ถ„์ด ์žˆ์—ˆ๋‹ค. ์šฐ์„ , ์กฐ๊ฑด์„ ์ถฉ์กฑํ•˜๊ธฐ ์ „๊นŒ์ง€๋Š” ์„œ์„œํžˆ ๋Š๋ ค์ง€๋Š” ์Šฌ๋กœ์šฐ๋ชจ์…˜์ด ๋“ค์–ด๊ฐ€์•ผ๋งŒ ํ–ˆ๋‹ค. ๋”ฐ๋ผ์„œ ํŠธ๋ž™์ด๋ฆ„์„ SlowMotion Track์ด๋ผ๊ณ  ์ง€์—ˆ๋‹ค.

๋˜ํ•œ ์ฐธ๊ณ  ํ”„๋กœ์ ํŠธ์˜ ์ฝ”๋“œ์—์„œ๋Š” ๋Š๋ ค์ง€๋Š” ์กฐ๊ฑด์„ Swich๋ฌธ์œผ๋กœ ํŒ๋ณ„ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์กฐ๊ฑด์ด ๋Š˜์–ด๋‚ ์ˆ˜๋ก ์ฝ”๋“œ๋„ ๊ธธ์–ด์ง€๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค. ์ด ์กฐ๊ฑด์„ ๋‹ค๋ฅธ ์Šคํฌ๋ฆฝํŠธ์—์„œ ๊ด€๋ฆฌํ•˜๋ฉด์„œ ํŠธ๋ž™์€ ๊ด€๋ฆฌ๋งŒ ํ•˜๋Š” ์šฉ๋„๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์—ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ๋ชฉ๋ก

ํŠธ๋ž™๊ณผ ๊ด€๋ จ๋œ ๋ชฉ๋ก

  • SlowMotionTrack
  • SlowMotionClip
  • SlowMotionBehaviour
  • SlowMotionMixerBehaviour
  • SlowMotionClipInspector(Editor)

๊ทธ ์™ธ

  • TimelineSpeedController
    ํƒ€์ž„๋ผ์ธ์˜ ์‹œ๊ฐ„์„ ์กฐ์ ˆ
  • SlowMotionCondition
    ์กฐ๊ฑด์„ ๊ฑฐ๋Š” ์Šคํฌ๋ฆฝํŠธ. ์กฐ๊ฑด์„ ๊ฑฐ๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋”ฐ๋กœ ๋งŒ๋“ค๊ณ  ์ด ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ƒ์†ํ•ด์•ผ๋งŒ ํ•œ๋‹ค.

MixerBehaviour

๊ธฐ๋ณธ์ ์ธ ํŠธ๋ž™์˜ ํ‹€์€ ๊ทธ๋Œ€๋กœ ๊ฐ€์ ธ์™”๊ณ , ๊ฐœ์กฐํ•œ ๋ถ€๋ถ„์€ ์กฐ๊ฑด์„ ํŒ๋ณ„ํ•˜๋Š” MixerBehaviour ์Šคํฌ๋ฆฝํŠธ์˜ Switch๋ฌธ์ด๋‹ค. 3๊ฐ€์ง€ case๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค. ContinuousSlowing์€ ๋‹จ์ผ๋กœ ๋™์ž‘ํ•˜๋ฉฐ SlowDownAndJumpToMarker์™€ Marker๋Š” ์„œ๋กœ ์Œ์„ ์ด๋ฃจ์–ด์•ผ ํ•œ๋‹ค.

  1. ContinuousSlowing
    ์กฐ๊ฑด์ด false๋ผ๋ฉด ์ง€์ •ํ•œ ์†๋„๊นŒ์ง€ ์ ์ฐจ ๋Š๋ ค์ง€๊ณ , True๊ฐ€ ๋˜๋ฉด ๋‹ค์‹œ 1๋กœ ํšŒ๋ณต๋œ๋‹ค.
  2. SlowDownAndJumpToMarker
    ์กฐ๊ฑด์ด false๋ผ๋ฉด ์ง€์ •ํ•œ ์†๋„๊นŒ์ง€ ์ ์ฐจ ๋Š๋ ค์ง€๊ณ , True๊ฐ€ ๋˜๋ฉด Marker๊ฐ€ ์œ„์น˜ํ•œ ํƒ€์ž„๋ผ์ธ ์‹œ๊ฐ„๋Œ€๋กœ ์ ํ”„ํ•œ๋‹ค.
  3. Marker
    2๋ฒˆ๊ณผ ์—ฐ๊ด€๋œ case์ด๋‹ค. ์ ์ฐจ ์†๋„๊ฐ€ 1๋กœ ํšŒ๋ณต๋œ๋‹ค.

1๋ฒˆ๊ณผ 2๋ฒˆ์€ ๋Š๋ ค์ง€๋Š” ์กฐ๊ฑด์„ ๋ฐ›๋Š”๋‹ค. ๊ทธ ์กฐ๊ฑด์€ SlowMotionCondition์„ ์ƒ์†๋ฐ›์€ ์Šคํฌ๋ฆฝํŠธ์—๊ฒŒ์„œ ๊ฐ€์ ธ์˜จ๋‹ค.

๋‹ค์šด๋กœ๋“œ ๋ฐ ์‚ฌ์šฉ๋ฒ•

02

๐Ÿ‘‰ ๋‹ค์šด๋กœ๋“œ ๋งํฌ

์œ„์˜ ๋‹ค์šด๋กœ๋“œ ๋งํฌ์—์„œ *.unityPackage๋ฅผ ๋‹ค์šด๋กœ๋“œ ๋ฐ›๊ณ  ์œ ๋‹ˆํ‹ฐ์—์„œ ์—ด๋ฉด CustomPlayables/SlowMotion ํŒŒ์ผ์ด ์ƒ์„ฑ๋œ๋‹ค.

์‚ฌ์ „์„ค์ •

๋จผ์ €, ํƒ€์ž„๋ผ์ธ์˜ ์‹œ๊ฐ„์„ ์กฐ์ ˆํ•  ์ˆ˜ ์žˆ๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ [Add Component]ํ•ด์•ผํ•œ๋‹ค.

03

TimelineSpeedController ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๊ฐ์ฒด์— ๋ถ™์ด๊ณ , Director ๋ณ€์ˆ˜์— ํ˜„์žฌ ์‚ฌ์šฉํ•  [Playable Director]๋ฅผ ๋“œ๋ž˜๊ทธ & ๋“œ๋žํ•œ๋‹ค.

ํŠธ๋ž™ ์ƒ์„ฑ

04

ํƒ€์ž„๋ผ์ธ์—์„œ ํŠธ๋ž™์„ ์ƒ์„ฑํ•œ๋‹ค. CustomTimeline>SlowMotion์„ ํด๋ฆญํ•˜์—ฌ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค. ์—ฌ๊ธฐ์„œ CustomTimeline ํ•˜์œ„์— ๋“ค์–ด๊ฐ€ ์žˆ๋Š” ์ด์œ ๋Š” SlowMotion Track์˜ namespace๊ฐ€ CustomTimeline์ด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

05

์‚ฌ์ „์„ค์ •์—์„œ Add Componentํ•œ [TimelineSpeedController.cs]๊ฐ€ ๋“ค์–ด์žˆ๋Š” ๊ฐ์ฒด๋ฅผ ๋“œ๋ž˜๊ทธ & ๋“œ๋žํ•œ๋‹ค.

ํด๋ฆฝ ์„ค์ •

06

์ƒ์„ฑํ•œ ํŠธ๋ž™์— [์šฐํด๋ฆญ] ํ›„ [Add Slow Motion Clip]๋กœ ํด๋ฆฝ์„ ๋งŒ๋“ ๋‹ค.

07

ํด๋ฆฝ์„ ํด๋ฆญํ•˜๊ณ  Inspector์—์„œ ํด๋ฆฝ์— ๋Œ€ํ•œ ์„ค์ •์„ ์ง„ํ–‰ํ•œ๋‹ค.

  1. Action
    ContinuousSlowing/SlowDownAndJumpToMarker/Marker ์ค‘์— ์„ ํƒ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
    ContinuousSlowing์€ ๋‹จ์ผ๋กœ ๋™์ž‘ํ•˜๋ฉฐ
    SlowDownAndJumpToMarker์™€ Marker๋Š” ์„œ๋กœ ์Œ์„ ์ด๋ฃจ์–ด์•ผ ํ•œ๋‹ค.
    ์ž์„ธํ•œ ์‚ฌํ•ญ์€ ์œ„๋ฅผ ์ฐธ์กฐ. (MixerBehaviour)
  2. Marker Label
    ์ด๋ฆ„์„ ์“ฐ๋ฉด ์ž๋™์œผ๋กœ ํด๋ฆฝ์˜ ์ œ๋ชฉ์œผ๋กœ ์ž‘์„ฑ๋œ๋‹ค.
    ์ค‘์š”! ์—ฌ๊ธฐ์„œ Marker Label์€ ContinuousSlowing์˜ ๊ฒฝ์šฐ ์•„๋ฌด๋Ÿฐ ํšจ๊ณผ๊ฐ€ ์—†์ง€๋งŒ, SlowDownAndJumpToMarker์™€ Marker๋Š” ์„œ๋กœ์˜ ์ง์„ Marker Label์ด ์ผ์น˜ํ•ด์•ผ๋งŒ ์ง์œผ๋กœ ์ธ์‹ํ•˜๊ธฐ ๋–„๋ฌธ์— ๊ผญ ์ž‘์„ฑํ•ด์•ผ๋งŒ ํ•œ๋‹ค.
  3. Event_Method
    ์กฐ๊ฑด์ด ๋“ค์–ด๊ฐ„ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์—ฌ๊ธฐ์— ๋„ฃ์–ด์ค€๋‹ค. SlowMotionCondition์„ ์ƒ์†๋ฐ›์€ ์Šคํฌ๋ฆฝํŠธ์—ฌ์•ผ๋งŒ ํ•œ๋‹ค.
  4. Min Timeline Speed
    ํƒ€์ž„๋ผ์ธ์˜ ์ตœ์†Œ ์†๋„๋ฅผ ๋งํ•œ๋‹ค. ์ ์  ์ค„์–ด๋“ค์–ด ๋ฉˆ์ถ”๊ณ  ์‹ถ๋‹ค๋ฉด 0์„ ๋„ฃ์œผ๋ฉด ๋œ๋‹ค.
  5. Lerp Speed
    ์œ„์˜ Min Timeline Speed๊นŒ์ง€ ์–ผ๋งˆ๋‚˜ ๋น ๋ฅธ ์†๋„๋กœ ์ค„์–ด๋“ค ๊ฒƒ์ธ์ง€ ์„ค์ •ํ•œ๋‹ค. (Time.DeltaTime * Lerp Speed)

SlowDownAndJumpToMarker์™€ Marker์— ๋Œ€ํ•œ ์„ค๋ช…์ด ๋ถ€์กฑํ•œ ๊ฒƒ ๊ฐ™์•„ ์ถ”๊ฐ€๋กœ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์™”๋‹ค.

08

์ด๋Ÿฐ ์‹์œผ๋กœ Marker Label์˜ String๊ฐ’์„ ๋น„๊ตํ•˜์—ฌ ์„œ๋กœ์˜ ์ง์„ ์ฐพ์•„๊ฐ„๋‹ค.

์กฐ๊ฑด ์„ค์ •

์กฐ๊ฑด ์Šคํฌ๋ฆฝํŠธ๋Š” SlowMotionCondition์„ ์ƒ์†๋ฐ›์Œ์œผ๋กœ์จ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค.

์ค‘์š”ํ•œ ๊ฒƒ์€ SlowMotionCondition์˜ GetEventCondition()์„ ๋ฌด์กฐ๊ฑด overrideํ•ด์•ผ ํ•œ๋‹ค๋Š” ์ ์ด๋‹ค. ํ•ด๋‹น ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์—ด์–ด๋ณด๋ฉด Exception์œผ๋กœ ํ‘œ๊ธฐํ•ด ๋†“์€ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;

namespace CustomTimeline
{
    [ExecuteInEditMode]
    public class SlowMotionCondition : MonoBehaviour
    {
        public bool skip = false;

        public virtual bool GetEventCondition() // override ํ•„์ˆ˜
        {
            throw new System.Exception("Not overwritten");
        }

        public bool CheckCheckEventCondition()
        {
            if (skip)
                return true;
            return GetEventCondition();
        }

    }
}

GetEventCondition() ํ•จ์ˆ˜๋ฅผ override ํ•œ ๋’ค ์กฐ๊ฑด์„ ์ถฉ์กฑํ•˜๋ฉด true๋ฅผ returnํ•˜๋Š” ๊ตฌ์กฐ๋กœ ์ž‘์„ฑํ•˜๋ฉด ๋œ๋‹ค. ์•„์ฃผ ๊ฐ„๋‹จํ•˜๊ฒŒ bool๊ฐ’์„ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด ํ…Œ์ŠคํŠธํ•ด๋ณผ ์ˆ˜ ์žˆ๋‹ค.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

namespace CustomTimeline
{
    public class SlowMotionEvent_Example : SlowMotionCondition
    {
        public bool checkTemp;
        public override bool GetEventCondition()
        {
            return checkTemp;
        }
    }
}

์ด๋ ‡๊ฒŒ ๋งŒ๋“  ์กฐ๊ฑด ์Šคํฌ๋ฆฝํŠธ๋ฅผ Clip์˜ Event_Method์— ๋„ฃ์œผ๋ฉด ๋œ๋‹ค.

ํ…Œ์ŠคํŠธ

TimelineSpeedController.cs์— [ExecuteInEditMode]๋ฅผ ๋„ฃ์—ˆ์œผ๋‹ˆ ์œ ๋‹ˆํ‹ฐ๋ฅผ PlayMode๋กœ ๋งŒ๋“ค ํ•„์š” ์—†์ด ํ”Œ๋ ˆ์ด ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด์ง€ ์•Š์•„๋„ ํƒ€์ž„๋ผ์ธ์˜ ํ”„๋ฆฌ๋ทฐ์—์„œ ํ™•์ธ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

TimelineSpeed Track

์œ„์—์„œ ์„ค๋ช…ํ–ˆ๋˜ SlowMotion Track์€ ์กฐ๊ฑด์— ๋”ฐ๋ผ์„œ ์‹œ๊ฐ„์„ ์กฐ์ ˆํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ์˜€๋‹ค. ์ด๋ฒˆ์— ์„ค๋ช…ํ•  TimelineSpeed Track์€ ๊ฐ„๋‹จํ•˜๊ฒŒ ์‹œ๊ฐ„๋งŒ ์กฐ์ ˆํ•˜๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.

์ฐธ๊ณ  ํ”„๋กœ์ ํŠธ: Default Playables - Time Dilation

์ด์ „์— ์„ค๋ช…ํ–ˆ๋˜ Default Playables์— ํฌํ•จ๋˜์–ด ์žˆ๋Š” Time DilationํŠธ๋ž™์„ ์ฐธ๊ณ ํ•˜์˜€๋‹ค. ํ•ด๋‹น ํŠธ๋ž™์€ TimeScale์„ ์กฐ์ ˆํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ๋กœ์จ, ํƒ€์ž„๋ผ์ธ์˜ ์‹œ๊ฐ„๋งŒ์„ ์กฐ์ ˆํ•ด์•ผํ•˜๋Š” ํ”„๋กœ์ ํŠธ์˜ ์„ฑ๊ฒฉ๊ณผ๋Š” ๋งž์ง€ ์•Š์•„ ๊ฐœ์กฐํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.

๊ฐœ์กฐ

TimeScale์„ ์กฐ์ ˆํ•˜๋Š” ๋ถ€๋ถ„์„ Timeline์˜ Playables ์ž์ฒด์˜ ์†๋„๋ฅผ ๋Šฆ์ถ”๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ณ€๊ฒฝํ•˜์˜€๋‹ค.

๋‹ค์šด๋กœ๋“œ ๋ฐ ์‚ฌ์šฉ๋ฒ•

09

๐Ÿ‘‰ ๋‹ค์šด๋กœ๋“œ ๋งํฌ

์œ„์˜ ๋‹ค์šด๋กœ๋“œ ๋งํฌ์—์„œ *.unityPackage๋ฅผ ๋‹ค์šด๋กœ๋“œ ๋ฐ›๊ณ  ์œ ๋‹ˆํ‹ฐ์—์„œ ์—ด๋ฉด CustomPlayables/TimelineSpeed ํŒŒ์ผ์ด ์ƒ์„ฑ๋œ๋‹ค.

์‚ฌ์ „ ์„ค์ •

SlowMotion Track๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ํƒ€์ž„๋ผ์ธ์˜ ์‹œ๊ฐ„์„ ์กฐ์ ˆํ•  ์ˆ˜ ์žˆ๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ [Add Component]ํ•ด์•ผํ•œ๋‹ค.

03

TimelineSpeedController ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๊ฐ์ฒด์— ๋ถ™์ด๊ณ , Director ๋ณ€์ˆ˜์— ํ˜„์žฌ ์‚ฌ์šฉํ•  [Playable Director]๋ฅผ ๋“œ๋ž˜๊ทธ & ๋“œ๋žํ•œ๋‹ค.

ํŠธ๋ž™ ์ƒ์„ฑ

10

ํƒ€์ž„๋ผ์ธ์—์„œ ํŠธ๋ž™์„ ์ƒ์„ฑํ•œ๋‹ค. CustomTimeline>TimelineSpeed Track์„ ํด๋ฆญํ•˜์—ฌ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค. ์—ฌ๊ธฐ์„œ CustomTimeline ํ•˜์œ„์— ๋“ค์–ด๊ฐ€ ์žˆ๋Š” ์ด์œ ๋Š” TimelineSpeed Track์˜ namespace๊ฐ€ CustomTimeline์ด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

11

์‚ฌ์ „์„ค์ •์—์„œ Add Componentํ•œ [TimelineSpeedController.cs]๊ฐ€ ๋“ค์–ด์žˆ๋Š” ๊ฐ์ฒด๋ฅผ ๋“œ๋ž˜๊ทธ & ๋“œ๋žํ•œ๋‹ค.

ํด๋ฆฝ ์„ค์ •

12

์ƒ์„ฑํ•œ ํŠธ๋ž™์— [์šฐํด๋ฆญ] ํ›„ [Add Timeline Speed Clip]๋กœ ํด๋ฆฝ์„ ๋งŒ๋“ ๋‹ค.

13

ํด๋ฆฝ์„ ํด๋ฆญํ•˜๊ณ  Inspector์—์„œ ํด๋ฆฝ์— ๋Œ€ํ•œ ์„ค์ •์„ ์ง„ํ–‰ํ•œ๋‹ค.

์ค‘์š”ํ•œ ๊ฒƒ์€ Ease In/Out Duration๊ณผ TimeSpeed์ด๋‹ค.
๋ธ”๋ Œ๋”ฉ ๊ตฌ๊ฐ„๋™์•ˆ ์„œ์„œํžˆ ์†๋„๊ฐ€ ์กฐ์ ˆ๋˜๋ฉฐ, ํด๋ฆฝ์ด ์žˆ๋Š” ๊ตฌ๊ฐ„์€ Time Speed ๋ณ€์ˆ˜๊ฐ’์œผ๋กœ ์†๋„๊ฐ€ ์œ ์ง€๋˜๊ณ , ํด๋ฆฝ์ด ์—†๋Š” ๊ตฌ๊ฐ„์€ ์Šคํ”ผ๋“œ๊ฐ€ 1๋กœ ๋Œ์•„๊ฐ„๋‹ค.

ํ…Œ์ŠคํŠธ

์œ„์˜ SlowMotion์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ TimelineSpeedController.cs์— [ExecuteInEditMode]๋ฅผ ๋„ฃ์—ˆ๊ธฐ ๋•Œ๋ฌธ์—, ์œ ๋‹ˆํ‹ฐ๋ฅผ PlayMode๋กœ ๋งŒ๋“ค ํ•„์š” ์—†์ด ํ”Œ๋ ˆ์ด ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด์ง€ ์•Š์•„๋„ ํƒ€์ž„๋ผ์ธ์˜ ํ”„๋ฆฌ๋ทฐ์—์„œ ํ™•์ธ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

๋งˆ๋ฌด๋ฆฌ

์ง€๊ธˆ๊นŒ์ง€ ํƒ€์ž„๋ผ์ธ์—์„œ ์‹œ๊ฐ„์„ ๋‹ค๋ฃจ๋Š” ๋ฒ•์— ๋Œ€ํ•ด ์‹ค์ œ ํ”„๋กœ์ ํŠธ์— ์‚ฌ์šฉํ•œ ์ฝ”๋“œ๋ฅผ ๊ฐ€์ง€๊ณ  ์•Œ์•„๋ณด์•˜๋‹ค. ๊ณต์œ ํ•œ ์ฝ”๋“œ๋“ค์€ ๋ชจ๋‘ ํ”„๋กœ์ ํŠธ์šฉ์œผ๋กœ ์ œ์ž‘ํ•œ ๊ฒƒ์œผ๋กœ์จ ์ž…๋ง›์— ๋งž์ถฐ ๋ฐ”๊ฟ” ์‚ฌ์šฉํ•ด์•ผ ํ• ํ…Œ์ง€๋งŒ ํƒ€์ž„๋ผ์ธ์—์„œ ์‹œ๊ฐ„์„ ์กฐ์ ˆํ•˜๋ ค๋Š” ๋ถ„๋“ค๊ป˜ ์กฐ๊ธˆ์ด๋‚˜๋งˆ ์‹ค๋งˆ๋ฆฌ๊ฐ€ ๋˜์—ˆ์œผ๋ฉด ํ•œ๋‹ค.


ยฉ 2022. All rights reserved.