[UE5] ๐Ÿ•น๏ธ Enhanced Input System์œผ๋กœ 3์ธ์นญ ์กฐ์ž‘ ๊ตฌํ˜„ (2)

Singery00ยท2024๋…„ 3์›” 27์ผ
0

UE5 Blueprint

๋ชฉ๋ก ๋ณด๊ธฐ
5/29
post-thumbnail

๊ฐœ์š”

๐Ÿƒ ์ง€๋‚œ ํฌ์ŠคํŒ…์— ์–ธ๋ฆฌ์–ผ ์—”์ง„5์˜ Old Input System์„ ์‚ฌ์šฉํ•˜์—ฌ 3์ธ์นญ ์บ๋ฆญํ„ฐ ์กฐ์ž‘ ์‹œ์Šคํ…œ์„ ๊ตฌํ˜„ํ•ด๋ณด์•˜๋‹ค.

์ด๋ฒˆ์—๋Š” ๐Ÿ•น๏ธ Enhanced Input System์œผ๋กœ ๋™์ผํ•œ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•ด ๋ณผ ๊ฒƒ์ด๋‹ค.

์ด์ „ ํฌ์ŠคํŒ…์„ ๋ณด๊ณ  ์˜ค์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.
์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” Blueprint๋กœ ์ฝ”๋”ฉํ•˜์—ฌ ์บ๋ฆญํ„ฐ ์กฐ์ž‘์„ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.

1. ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ
2. ํ”„๋กœ์ ํŠธ ์„ค์ •
3. IA ์ƒ์„ฑ
4. IMC ์ƒ์„ฑ
5. ๋ธ”๋ฃจํ”„๋ฆฐํŠธ ์ฝ”๋”ฉ
6. ๊ฐœ์„ 

โ—๋ชจ๋“  ๊ณผ์ •์„ ํ•˜๋‚˜ํ•˜๋‚˜ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹คโ—
โ—์—”์ง„์—์„œ ํŽธ์˜๋ฅผ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•ด ์ž๋™์œผ๋กœ ์„ค์ •๋˜๋Š” ๊ฒฝ์šฐ๋„ ๋ชจ๋‘ ์„ค๋ช…ํ•˜๋‹ˆ ์ฐธ๊ณ ๋ฐ”๋ž๋‹ˆ๋‹คโ—


๋ณธ๋ก 

Blueprint์—๋””ํ„ฐ์˜ [Event Graph] ๋กœ ์ด๋™ํ•˜์ž.
Old Input System ํฌ์ŠคํŒ…์˜ Blueprint ์•กํ„ฐ๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•  ๊ฒƒ์ด๋‹ค.
๊ธฐ์กด์˜ ์ด๋ฒคํŠธ ๊ทธ๋ž˜ํ”„๋Š” ํ๋ฆ„์„ ๋Š๊ณ  ์˜†์œผ๋กœ ์น˜์šฐ๊ฑฐ๋‚˜ ๋ชจ๋‘ ์‚ญ์ œํ•ด์ฃผ์ž


๐ŸŽฎ Enhanced Input ๋ฐ›๊ธฐ

[Event Graph] ์—์„œ Get Player Controller ๋…ธ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์ž

๊ทธ๋ฆฌ๊ณ  Get Player Controller ์˜ ๋ฐ˜ํ™˜๊ฐ’์„ ๋Œ์–ด์„œ Enhanced Input Local Player Subsystem ์„ ๊ฒ€์ƒ‰ํ•ด์„œ ๋„ฃ์–ด์ฃผ์ž

์ด๋ ‡๊ฒŒ ๊ฒ€์ƒ‰ ํ›„ ์ถ”๊ฐ€ํ•˜๋ฉด ์•„๋ž˜์˜ ๋…ธ๋“œ๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค.
ํ•ด๋‹น ๋…ธ๋“œ๋Š” C++์—์„œ ์ž‘์—…ํ•  ๋•Œ ๋Œ€์†Œ๋ฌธ์ž๊นŒ์ง€ ๊ตฌ๋ณ„ํ•ด์„œ ์ง์ ‘ ์ž…๋ ฅํ•ด์ค˜์•ผ ํ•˜๋‹ˆ ์ด๋ฆ„์„ ์™ธ์›Œ๋‘์ž...

Enhanced Input Local Player Subsystem์˜ ๋ฐ˜ํ™˜๊ฐ’์„ ๋Œ์–ด์„œ Add Mapping Context๋ฅผ ๊ฒ€์ƒ‰ํ•ด์„œ ์ถ”๊ฐ€ํ•ด์ฃผ์ž

Add Mapping Context ๋…ธ๋“œ์˜ [Mapping Context]์˜ ์•„๋ž˜ [Select Asset]์„ ๋ˆŒ๋Ÿฌ ์šฐ๋ฆฌ๊ฐ€ ์ƒ์„ฑํ•œ IMC_Player_Input์œผ๋กœ ์„ค์ •ํ•ด์ฃผ์ž
๊ทธ๋ฆฌ๊ณ  Event BeginPlay๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ๋ฐฉ๊ธˆ ์ถ”๊ฐ€ํ•œ ๋…ธ๋“œ์™€ ํ๋ฆ„์„ ์—ฐ๊ฒฐํ•ด์ฃผ์ž.

์ด๊ฒƒ์œผ๋กœ Enhanced Input System์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.
์ด์ œ Input Action์„ ์ถ”๊ฐ€ํ•ด์„œ ์ง์ ‘ ์›€์ง์ž„์— ๋Œ€ํ•œ ๋‚ด์šฉ์„ ์ฝ”๋”ฉํ•˜์ž.


๐ŸŽฎ Input Action ์ฝ”๋”ฉ

์•„๋ž˜์— ์šฐ๋ฆฌ๊ฐ€ ์ƒ์„ฑํ•œ IA_Jump, IA_Look, IA_Move ๋…ธ๋“œ 3๊ฐœ๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์ž.
์–ธ๋ฆฌ์–ผ์—์„œ ์ œ๊ณตํ•˜๋Š” ๋™์ผํ•œ ์ด๋ฆ„์ด ์žˆ์œผ๋‹ˆ ์ €์žฅ์œ„์น˜๋ฅผ ์ž˜ ๋ณด๊ณ  ๊ฐ€์ ธ์˜ค์ž.

ํ˜น์‹œ ๋ถˆํŽธํ•œ ์‚ฌ๋žŒ์€ ์ด๋ฆ„์„ ๋ณ€๊ฒฝํ•ด๋„ ๋ฌด๋ฐฉํ•˜๋‹ค!

๊ทธ๋ฆฌ๊ณ  IA_Move์™€ IA_Look์˜ Action Value ๋ฐ˜ํ™˜ํ•€์„ ์šฐํด๋ฆญ ํ›„ Splitํ•˜์ž

W,A,S,D์œผ๋กœ ์ด๋™ ์กฐ์ž‘๋ถ€ํ„ฐ ๊ตฌํ˜„ํ•˜๊ฒ ๋‹ค.

โŒจ๏ธ A,D ์ด๋™ ๊ตฌํ˜„

๋นˆ๊ณต๊ฐ„์„ ์šฐํด๋ฆญ ํ›„ Add Movement Input ๋…ธ๋“œ๋ฅผ ๊ฒ€์ƒ‰ํ›„ 2๊ฐœ ์ถ”๊ฐ€ํ•œ๋‹ค.
๊ทธ๋ฆฌ๊ณ  IA_Move์˜ [Triggered]ํ๋ฆ„์„ ์ด์–ด์ฃผ์ž

์ขŒ์šฐ ์ด๋™์„ ๋จผ์ € ๋งŒ๋“ค๊ฒ ๋‹ค.

  1. IA_Move์˜ [Action Value X]๋ฅผ ์ฒซ๋ฒˆ์งธ Add Movement Input ๋…ธ๋“œ์˜ [Scale Value]์— ์—ฐ๊ฒฐ
  1. Get Control Rotation ๋…ธ๋“œ ์ถ”๊ฐ€
  2. Get Right Vector ๋…ธ๋“œ ์ถ”๊ฐ€
    Math - Vector์˜ Get Right Vector๋ฅผ ๊ฐ€์ ธ์˜ค์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  1. Get control Rotationd์˜ [๋ฐ˜ํ™˜๊ฐ’]์„ Get Right Vector [์ž…๋ ฅ๊ฐ’]์— ์—ฐ๊ฒฐ
  1. Get Right Vector ๋…ธ๋“œ์˜ [๋ฐ˜ํ™˜๊ฐ’]์„ ์ฒซ๋ฒˆ์งธ Add Movement Input ๋…ธ๋“œ์˜ [World Direction]์— ์—ฐ๊ฒฐ

์—ฌ๊ธฐ๊นŒ์ง€ ์™„๋ฃŒํ–ˆ๋‹ค๋ฉด โ—์ปดํŒŒ์ผ ์ €์žฅโ—ํ›„ ํ”Œ๋ ˆ์ดํ•˜๋ฉด ์ขŒ์šฐ ์ด๋™์ด ๊ฐ€๋Šฅํ•ด์ง„๋‹ค.

โŒจ๏ธ W,S ์ด๋™ ๊ตฌํ˜„

์ด๋ฒˆ์—” ์•ž ๋’ค ์ด๋™์„ ๋งŒ๋“ค๊ฒ ๋‹ค.

  1. IA_Move์˜ [Action Value Y]๋ฅผ ๋‘๋ฒˆ์งธ Add Movement Input ๋…ธ๋“œ์˜ [Scale Value]์— ์—ฐ๊ฒฐ
  1. Get Control Rotation ๋…ธ๋“œ ์ถ”๊ฐ€
  2. Get Forward Vector ๋…ธ๋“œ ์ถ”๊ฐ€
    Math - Vector์˜ Get Forward Vector๋ฅผ ๊ฐ€์ ธ์˜ค์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  1. Get control Rotationd์˜ [๋ฐ˜ํ™˜๊ฐ’]์„ Get Forward Vector [์ž…๋ ฅ๊ฐ’]์— ์—ฐ๊ฒฐ
  1. Get Right Vector ๋…ธ๋“œ์˜ [๋ฐ˜ํ™˜๊ฐ’]์„ ์ฒซ๋ฒˆ์งธ Add Movement Input ๋…ธ๋“œ์˜ [World Direction]์— ์—ฐ๊ฒฐ

โ—์ปดํŒŒ์ผ ์ €์žฅโ—ํ›„ ํ”Œ๋ ˆ์ดํ•˜๋ฉด W,A,S,D๋กœ ์กฐ์ž‘์ด ๊ฐ€๋Šฅํ•ด์ง„๋‹ค!
ํ˜น์‹œ ์บ๋ฆญํ„ฐ๊ฐ€ ์ขŒ์šฐ๋ฐ˜์ „, ์ƒํ•˜๋ฐ˜์ „์œผ๋กœ ์ด๋™ํ•œ๋‹ค๋ฉด IA_Move์˜ [X], [Y]๊ฐ’์„ ๋ฐ˜๋Œ€๋กœ ๋„ฃ์—ˆ๋Š”์ง€ ํ™•์ธํ•˜์ž.

๊ทธ๋ž˜๋„ ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค๋ฉด IMC_Player_Input์—์„œ ๊ฐ ์ž…๋ ฅ Mapping์˜ Modifiers ๊ฐ’์ด ๋ฐ˜๋Œ€๋กœ ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์ž.

์•„๋ž˜๋Š” ์ „์ฒด ๋…ธ๋“œ ์‚ฌ์ง„์ด๋‹ˆ ๋น„๊ตํ•ด๋ณด์ž.


์ด๋ฒˆ์—๋Š” ๋งˆ์šฐ์Šค ์‹œ์  ์กฐ์ž‘์„ ๊ตฌํ˜„ํ•ด๋ณด์ž.

๐Ÿ–ฑ๏ธ ์ขŒ์šฐ ๋งˆ์šฐ์Šค ์‹œ์ 

๋นˆ๊ณต๊ฐ„์„ ์šฐํด๋ฆญ ํ›„ Add Controller Yaw Input๋…ธ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์•„๋ž˜ ์‚ฌ์ง„๊ณผ ๊ฐ™์ด ์„ ์„ ์ด์–ด์ฃผ๋ฉด ๋์ด๋‹ค.

ํ”Œ๋ ˆ์ด ํ•ด๋ณด๋ฉด ๋งˆ์šฐ์Šค ์ขŒ์šฐ ์‹œ์  ์กฐ์ž‘์ด ๊ฐ€๋Šฅํ•ด์ง„๋‹ค.


๐Ÿ–ฑ๏ธ ์ƒํ•˜ ๋งˆ์šฐ์Šค ์‹œ์ 

๋นˆ๊ณต๊ฐ„์„ ์šฐํด๋ฆญ ํ›„ Add Controller Pitch Input๋…ธ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์•„๋ž˜ ์‚ฌ์ง„๊ณผ ๊ฐ™์ด ์„ ์„ ์ด์–ด์ค€๋‹ค.

โ—์ปดํŒŒ์ผ ์ €์žฅโ—ํ›„ ํ”Œ๋ ˆ์ด ํ•ด๋ณด๋ฉด ๋งˆ์šฐ์Šค ์ƒํ•˜ ์‹œ์  ์กฐ์ž‘์ด ๊ฐ€๋Šฅํ•ด์ง„๋‹ค.

ํ˜น์‹œ ์ƒํ•˜ ์กฐ์ž‘์ด ์•ˆ๋œ๋‹ค๋ฉด ์ถ”๊ฐ€์„ค์ •์„ ํ•ด์ค˜์•ผ ํ•œ๋‹ค.

  1. ์ขŒ์ธก Componentsํƒญ์˜ Spring Arm์„ ํƒ
  2. ์šฐ์ธก Detailsํƒญ์˜ ๊ฒ€์ƒ‰์ฐฝ์—์„œ pawn๊ฒ€์ƒ‰
  3. Use Pawn Control Rotation์„ ์ฒดํฌํ•œ๋‹ค.

๊ทธ๋Ÿผ ์ƒํ•˜ ๋งˆ์šฐ์Šค ์‹œ์  ์กฐ์ž‘์ด ๊ฐ€๋Šฅํ•ด์ง„๋‹ค.


โŒจ๏ธ ์ ํ”„ ์กฐ์ž‘

Space Bar๋ฅผ ๋ˆŒ๋Ÿฌ ์ ํ”„ ์กฐ์ž‘์„ ๊ตฌํ˜„ํ•˜๊ฒ ๋‹ค.
๋นˆ๊ณต๊ฐ„์„ ์šฐํด๋ฆญ ํ›„ jump๋ผ๊ณ  ๊ฒ€์ƒ‰ํ•œ๋‹ค.
๊ทธ๋Ÿผ ํŒŒ๋ž€์ƒ‰ function์˜ Jump ๋…ธ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

๊ทธ๋ฆฌ๊ณ  IA_Jump ๋…ธ๋“œ์˜ [Triggered]ํ๋ฆ„์„ ์ด์–ด์ฃผ๋ฉด ๋์ด๋‹ค.

โ—์ปดํŒŒ์ผ ์ €์žฅโ—ํ›„ ํ”Œ๋ ˆ์ดํ•ด๋ณด๋ฉด ์ ํ”„๊ฐ€ ๊ฐ€๋Šฅํ•ด์ง„๋‹ค!
๋งŒ์•ฝ ์ ํ”„๊ฐ€ ๋„ˆ๋ฌด ์•ฝํ•œ ๊ฒƒ ๊ฐ™๋‹ค๋ฉด ์ถ”๊ฐ€ ์„ค์ •์œผ๋กœ ์กฐ์ ˆ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

  1. ์ขŒ์ธก Componentsํƒญ์—์„œ BP_Player ์„ ํƒ
  2. ์šฐ์ธก Detailsํƒญ์—์„œ jump ๊ฒ€์ƒ‰
  3. ์›ํ•˜๋Š” ๊ฐ’์œผ๋กœ ์กฐ์ ˆ


๋งˆ๋ฌด๋ฆฌ

์ด๊ฒƒ์œผ๋กœ Enhanced Input System์„ ์‚ฌ์šฉํ•˜์—ฌ ์–ธ๋ฆฌ์–ผ ์—”์ง„5์—์„œ ์บ๋ฆญํ„ฐ๋ฅผ ์กฐ์ž‘์„ ๋ชจ๋‘ ๊ตฌํ˜„ํ•˜์˜€๋‹ค.

๋‹ค์Œ ํฌ์ŠคํŒ…์€ ๊ฐœ์„ ์ด ํ•„์š”ํ•œ ๊ฒƒ๋“ค์„ ์ˆ˜์ •ํ•ด๋ณด๊ฒ ๋‹ค.

1. ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ
2. ํ”„๋กœ์ ํŠธ ์„ค์ •
3. IA ์ƒ์„ฑ
4. IMC ์ƒ์„ฑ
5. ๋ธ”๋ฃจํ”„๋ฆฐํŠธ ์ฝ”๋”ฉ
6. ๊ฐœ์„ 

profile
๊ฒŒ์ž„ ๊ฐœ๋ฐœ์ž๊ฐ€ ๋˜์–ด๋ณด์ž

0๊ฐœ์˜ ๋Œ“๊ธ€