[UE5] ๐Ÿ–ง ๋ฉ€ํ‹ฐํ”Œ๋ ˆ์ด Replication (8)

Singery00ยท2024๋…„ 8์›” 9์ผ
0

UE5 Blueprint

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

๊ฐœ์š”

๐Ÿ–ง Unreal์˜ Replication ๊ฐœ๋…์„ ์•Œ์•„๋ณด๊ณ  ๋ฉ€ํ‹ฐํ”Œ๋ ˆ์ด๋ฅผ ๋งŒ๋“ค์–ด๋ณด์ž.

์ˆ˜๋งŽ์€ ๊ฒŒ์ž„ ์žฅ๋ฅด๊ฐ€ ์žˆ์ง€๋งŒ ๊ทธ ์ค‘์—์„œ๋Š” ํ˜ผ์ž์„œ๋Š” ํ”Œ๋ ˆ์ดํ•  ์ˆ˜ ์—†๊ฑฐ๋‚˜, ์—ฌ๋Ÿฟ์ด์„œ ํ•˜๋ฉด ๋” ์žฌ๋ฏธ์žˆ๋Š” ์žฅ๋ฅด๊ฐ€ ์žˆ๋‹ค.
์ด๋•Œ, ์—ฌ๋Ÿฌ ์‚ฌ๋žŒ์ด ๋ชจ์—ฌ ํ•จ๊ป˜ ํ”Œ๋ ˆ์ดํ•˜๋Š” ๊ฒƒ์„ ๋ฉ€ํ‹ฐํ”Œ๋ ˆ์ด๋ผ๊ณ  ํ•œ๋‹ค.

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

Replication ๊ฐœ๋…
Replication ์‹œ๋ฆฌ์ฆˆ
Replication ๊ฐ„๋‹จ ์˜ˆ์ œ
Session ๊ธฐ๋ฐ˜ ๋ฉ€ํ‹ฐํ”Œ๋ ˆ์ด ์˜ˆ์ œ


๋ณธ๋ก 

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” Widget์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

๊ณต์œ ๋˜์–ด์•ผ ํ•˜๋Š” Widget, ๊ฐ Client์—๊ฒŒ๋งŒ ๋ณด์—ฌ์•ผ ํ•˜๋Š” Widget์— ๋Œ€ํ•ด์„œ ๋ชจ๋‘ ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.


์œ„์ ฏ ์ œ์ž‘

๊ฐ„๋‹จํ•˜๊ฒŒ This is test widget ํ…์ŠคํŠธ๋ฅผ ๊ฐ€์ง„ ์œ„์ ฏ์„ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.

์œ„์ ฏ ์ƒ์„ฑ

None Replicate

์ด์ œ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ E ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋ฉด ์œ„์ ฏ์„ ์ถ”๊ฐ€ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

Create Widget์œผ๋กœ WB_Test๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ์ด๋ฒคํŠธ๋ฅผ ๋งŒ๋“ค์—ˆ๊ณ ,

์ž…๋ ฅ ์‹œ ์‹คํ–‰ํ•ด์ฃผ๊ฒ ์Šต๋‹ˆ๋‹ค.

ํ”Œ๋ ˆ์ดํ•ด๋ณด๋ฉด ์ž…๋ ฅ๋งˆ๋‹ค ๊ฐ๊ฐ์˜ Client์—๊ฒŒ ์ƒ์„ฑ๋˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Run On Server

์ด๋ฒˆ์—” Run On Server ์ด๋ฒคํŠธ์— ์—ฐ๊ฒฐ ํ›„ ์‹คํ–‰ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

ํ”Œ๋ ˆ์ดํ•ด๋ณด๋ฉด?

์•„๋ฌด์ผ๋„ ๋ฐœ์ƒํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
๊ทธ๋ฆฌ๊ณ  ์ข…๋ฃŒํ•˜๋ฉด "์ƒ์„ฑ๋œ ์œ„์ ฏ์ด Validํ•˜์ง€ ์•Š์•„ ์ฝ์„ ์ˆ˜ ์—†๋‹ค" ๊ทธ๋Ÿฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

Test Widget ๋ณ€์ˆ˜๋ฅผ Replicate ํ•ด์ฃผ์–ด๋„ ๊ฐ™์€ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.

์œ„์ ฏ์— ๋Œ€ํ•œ ๋‚ด์šฉ์€ ๋งŽ์€ ์˜๊ฒฌ๋“ค์ด ์žˆ๋Š”๋ฐ ์•„๋ž˜ ํฌ๋Ÿผ์—์„œ ํ™•์ธํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๊ด€๋ จ ํฌ๋Ÿผ

๋‚ด์šฉ์„ ์ •๋ฆฌํ•˜์ž๋ฉด

  1. ์œ„์ ฏ์€ ๋กœ์ปฌ์—์„œ๋งŒ ์กด์žฌํ•˜๋ฉฐ ๋ณต์ œ(Replication) ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  2. ์œ„์ ฏ์€ ์„œ๋ฒ„์—์„œ ์ƒ์„ฑํ•˜๋Š” ๊ทธ๋ƒฅ ๋™์ž‘ํ•˜์ง€ ์•Š๋Š” ์ž˜๋ชป๋œ ๋ฐฉ๋ฒ•์ด๋‹ค.

2๋ฒˆ์„ ์ข€ ๋” ์ž์„ธํžˆ ์„ค๋ช…ํ•˜๋ฉด ์œ„์ ฏ์€ ํด๋ผ์ด์–ธํŠธ์—์„œ๋งŒ ์ž‘๋™ํ•˜๋ฏ€๋กœ ์„œ๋ฒ„์—์„œ ์‹คํ–‰ํ•  ๊ฒฝ์šฐ ์‹คํŒจํ•œ๋‹ค. ๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ์œ„์ ฏ ๋ณ€์ˆ˜๋ฅผ Replicateํ•ด์ฃผ์–ด๋„ ๋™์ผํ•˜๊ฒŒ ์‹คํŒจํ•œ ๊ฒƒ์ด์ฃ .

Multicast

๊ทธ๋ ‡๋‹ค๋ฉด Multicast๋ฅผ ํ•˜๋ฉด ์–ด๋–ป๊ฒŒ ๋ ๊นŒ์š”??

ํ”Œ๋ ˆ์ดํ•ด๋ณด๋ฉด 1๋ฒˆ์—์„œ ์‹คํ–‰ํ•˜์—ฌ๋„ ๋ชจ๋“  Client์—๊ฒŒ ์œ„์ ฏ์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์ข…๋ฃŒํ•˜๋ฉด ์—ญ์‹œ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์ฃ .

Run On Owning Client

์ด๋ฒˆ์—” Run On Owning Client๋กœ ์‹คํ–‰ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

Multicast์˜ ์œ„์น˜์— ๋ณ€๊ฒฝํ•ด์ฃผ์„ธ์š”.

์‹คํ–‰ํ•˜๋ฉด ๊ฐ Client์—๊ฒŒ ์œ„์ ฏ์ด ์ƒ์„ฑ๋˜๋ฉฐ ์˜ค๋ฅ˜๋˜ํ•œ ๋ฐœ์ƒํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์ถฉ๋Œ ์‹œ ์ถ”๊ฐ€ํ•ด์ค€๋‹ค๋ฉด?

Blueprint ์ œ์ž‘

๋ฉ€ํ‹ฐํ”Œ๋ ˆ์ด์—์„œ ์ถฉ๋Œ์€ ์„œ๋ฒ„๊ฐ€ ๊ด€์žฅํ•œ๋‹ค๊ณ  ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๊ทธ๋ ‡๋‹ค๋ฉด ์ถฉ๋Œ ์‹œ ํ”Œ๋ ˆ์ด์–ด์˜ Interaction ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์‹คํ–‰ํ•ด์„œ ์œ„์ ฏ์„ ์ถ”๊ฐ€ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

์ƒˆ๋กœ์šด ๋ธ”๋ฃจํ”„๋ฆฐํŠธ๋ฅผ ๋งŒ๋“ค์–ด์„œ Overlap์‹œ์— Interaction ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ˜ธ์ถœํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค.

Run On Owning Client

์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ํ˜ธ์ถœ๋  ๋•Œ Run On Owning Client๋ฅผ ์‹คํ–‰ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

๋ชจ๋“  Client์—๊ฒŒ ์‹คํ–‰์ด ๋˜์ฃ .
์ด๋Š” ์ถฉ๋Œ ์ด๋ฒคํŠธ ์‹œ ์†Œ์œ ๊ถŒ์— ๋Œ€ํ•œ ๋ฌธ์ œ๋กœ ๋ฐœ์ƒํ•ด ๋ชจ๋“  Client์—๊ฒŒ์„œ ํ˜ธ์ถœ๋˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์€ ์†Œ์œ ๊ถŒ์„ ์ง€์ •ํ•ด์ฃผ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์†Œ์œ ๊ถŒ ์ง€์ •

Run On Server

Run On Server๋ฅผ ๊ฑฐ์ณ์„œ ์‹คํ–‰ํ•˜๊ฑฐ๋‚˜,

Switch Has Authority

์ถฉ๋Œ ์‹œ ๋ฐœ์ƒํ•˜๋Š” ์ด๋ฒคํŠธ๋ฅผ ์„œ๋ฒ„์—์„œ๋งŒ ์‹คํ–‰ํ•˜๊ณ  ์•กํ„ฐ์˜ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

Switch Has Authority๋ฅผ ์‚ฌ์šฉํ–ˆ์œผ๋‹ˆ ํ”Œ๋ ˆ์ด์–ด๋Š” Run On Server๋ฅผ ๊ฑฐ์น  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

๋‘ ๋ฐฉ์‹ ๋ชจ๋‘๋‹ค ๊ฐ Client๋งˆ๋‹ค ๋”ฐ๋กœ ์‹คํ–‰๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


๋งˆ๋ฌด๋ฆฌ

์ถ”๊ฐ€์ ์œผ๋กœ Begin Play์™€ Create Widget์— ๋Œ€ํ•œ ์˜๊ฒฌ์ด ์žˆ์–ด์„œ ๊ฐ€์ ธ ์™”์Šต๋‹ˆ๋‹ค.

Do not use begin play for widget construction unless you are making a single player game.
It runs begin play on client and server (separately)

  • On start:
    • Client โ†’ begin play โ†’ create widget from class = success
    • Server โ†’ begin play โ†’ create widget from class = always fail resulting in null return

Widgets will only work on clients so it will fail when running on rhe server.

์‹ฑ๊ธ€ ํ”Œ๋ ˆ์ด์–ด ๊ฒŒ์ž„์„ ๋งŒ๋“œ๋Š” ๊ฒฝ์šฐ๊ฐ€ ์•„๋‹ˆ๋ฉด Begin Play์—์„œ ์œ„์ ฏ์„ ์ƒ์„ฑํ•˜์ง€ ๋ง๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

์œ„์ ฏ์€ ํด๋ผ์ด์–ธํŠธ์—์„œ๋งŒ ์ž‘๋™ํ•˜๋ฏ€๋กœ ์„œ๋ฒ„์—์„œ ์‹คํ–‰ํ•  ๊ฒฝ์šฐ ์‹คํŒจํ•˜๋Š” ์•„๊นŒ์˜ 2๋ฒˆ ์ด์œ ๋กœ ์ธํ•œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

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

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