[UE5] ๐Ÿ’ฅ Pawn์ด ์ถฉ๋Œ์„ ๋ฌด์‹œํ•œ๋‹ค

Singery00ยท2024๋…„ 5์›” 19์ผ
0

UE5

๋ชฉ๋ก ๋ณด๊ธฐ
12/37
post-thumbnail

๊ฐœ์š”

๐Ÿ’ฅ Pawn์ด ์ถฉ๋Œ์„ ๋ฌด์‹œํ•˜๊ณ  ๋ฒฝ์„ ๋‹ค ๋šซ๊ณ  ๋‹ค๋‹ˆ๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋‹ค. ์›์ธ์„ ์‚ดํŽด๋ณด๊ณ  ํ•ด๊ฒฐํ•˜์ž.

๊ฐœ์ธ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋˜ ์ค‘ ํ•œ ๊ฐ€์ง€ ์ด์Šˆ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

๋ฐ”๋กœ Pawn์ด ์ถฉ๋Œ์„ ๋ฌด์‹œํ•˜๋Š” ๊ฒƒ ์ด์˜€๋‹ค.

Collision์— ์˜ํ–ฅ์„ ์ฃผ๋Š” ์š”์†Œ๋“ค์ด ๋„ˆ๋ฌด ๋งŽ์•„ ํ•˜๋‚˜์”ฉ ํ™•์ธํ•˜๋ฉฐ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

์ฒดํฌ๋ฆฌ์ŠคํŠธ๋ฅผ ์‚ดํŽด๋ณด๋ฉด์„œ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•˜๊ฒ ๋‹ค.

์–ธ๋ฆฌ์–ผ SetActorLocation() ๊ณต์‹ ๋ฌธ์„œ


๋ณธ๋ก 


๐Ÿ’ฅ Collision ์ด์Šˆ ์ฒดํฌ ๋ฆฌ์ŠคํŠธ

Collision์ด ์›ํ•˜๋Š”๋Œ€๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๋Š” ์ €๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๊ฐœ๋ฐœ์ž๋“ค์ด ํ•œ๋ฒˆ์”ฉ์€ ๊ฒช๊ฒŒ ๋˜๋Š” ๋ฌธ์ œ์ธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ Collision ์ด์Šˆ์— ๋Œ€ํ•ด์„œ ์ ๊ฒ€์‚ฌํ•ญ์„ ์ •๋ฆฌํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

  1. Mesh Collision ํ™•์ธ
  2. Collision Preset ํ™•์ธ
  3. ์ฝ”๋“œ ํ™•์ธ

Mesh Collision ํ™•์ธ

๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์œผ๋กœ ํ•ด๋‹น Mesh๊ฐ€ Collision์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”์ง€๋ฅผ ๊ฒ€์‚ฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

Mesh ์—๋””ํ„ฐ ์ฐฝ์„ ํ‚ค๋ฉด ์ƒ๋‹จ์— Collision์ด ์žˆ์Šต๋‹ˆ๋‹ค.
Collision์„ ๋ˆ„๋ฅด๋ฉด ์•„๋ž˜์— ๋‹ค์–‘ํ•œ Collisio์„ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Mesh ๋ชจ์–‘์— ๋งž๋Š” ๋””ํ…Œ์ผํ•œ Collision์„ ์›ํ•œ๋‹ค๋ฉด ํ•˜๋‹จ์˜ 'Auto Convex Collision'์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

๊ทธ ํ›„ ์šฐ์ธก ํ•˜๋‹จ์˜ Convex Decomposion์˜ Apply๋ฅผ ๋ˆŒ๋Ÿฌ์ค๋‹ˆ๋‹ค.

๊ทธ๋Ÿผ Mesh์— ์ดˆ๋ก์„ ์ด ์ƒ๊ธฐ๋Š”๋ฐ ์ด๊ฒƒ์ด Collision์ž…๋‹ˆ๋‹ค.

ํ˜น์‹œ ์ดˆ๋ก์„ ์ด ๋ณด์ด์ง€ ์•Š๋Š”๋‹ค๋ฉด Collision์„ ๋ˆŒ๋ €์„ ๋•Œ, Remove Collision์ด ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๋‹ค๋ฉด Collision์ด ์กด์žฌํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

Collision Preset ํ™•์ธ

Mesh์— Collision์ด ์žˆ๋‹ค๋ฉด ํ•ด๋‹น Mesh๋กœ ๋งŒ๋“  Blueprint๋ฅผ ์ผœ์ค๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  Details์—์„œ Collision์„ ๊ฒ€์ƒ‰ํ•ด Collision Presets๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

Collision Presets

์ฒซ ๋ฒˆ์งธ๋กœ, Collision Presets์ด ์–ด๋–ค ๊ฒƒ์œผ๋กœ ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
No Collision์ด๋ฉด ๋‹น์—ฐํžˆ ์ถฉ๋Œ์ด ์•ˆ๋˜๊ฒ ์ฃ ?

Collision Enabled

๋‘ ๋ฒˆ์งธ, Collision Enabled๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
No Collision, Query, Physics ๋‹ค์–‘ํ•œ ์„ค์ •๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ๋˜ํ•œ ํ™•์ธํ•ด์ฃผ์„ธ์š”.

์ผ๋ฐ˜์ ์ธ ๊ฒฝ์šฐ๋ผ๋ฉด Collision Enabled (Query and Physics)๋ฅผ ์„ ํƒํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

Collision Responses

๊ทธ ํ›„ ๊ฐ Trace์— ๋Œ€ํ•œ Collision Responses ์„ค์ •์„ ๋ด์ฃผ์„ธ์š”.
๋ณธ์ธ์˜ ์„ค๊ณ„์— ๋”ฐ๋ผ Overlap, Block์„ ์„ ํƒํ•ด์ฃผ์„ธ์š”.

์—ฌ๊ธฐ๊นŒ์ง€๊ฐ€ Collision์˜ ์ผ๋ฐ˜์ ์ด ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

์ €๋Š” ๋ชจ๋“  ์„ค์ •์ด ๋˜์–ด ์žˆ์Œ์—๋„ ๋ฌธ์ œ๊ฐ€ ํ•ด๊ฒฐ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿฌ๋‹ค ์ œ ํ”„๋กœ์ ํŠธ์˜ ์บ๋ฆญํ„ฐ๋Š” Character ํด๋ž˜์Šค๊ฐ€ ์•„๋‹Œ Pawn ํด๋ž˜์Šค์ธ ๊ฒƒ์ด ์ƒ๊ฐ๋‚ฌ์Šต๋‹ˆ๋‹ค.


์ฝ”๋“œ ํ™•์ธ

Pawn ํด๋ž˜์Šค๋Š” Character์™€ ๋‹ฌ๋ฆฌ 'Add Movement Input'์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ์•„๋ž˜์™€ ๊ฐ™์ด 'Set Actor Location'์„ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋™์„ ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

ํ•ด๋‹น ๋ถ€๋ถ„์ด ๋ฌธ์ œ์˜€์Šต๋‹ˆ๋‹ค.

Set Actor Location์€ ๋ง ๊ทธ๋Œ€๋กœ ์•กํ„ฐ์˜ ์œ„์น˜๋ฅผ ํ•ด๋‹น ์ขŒํ‘œ๋กœ ์ด๋™ํ•˜๋Š” ๊ฒƒ ์ž…๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ์ถฉ๋Œ์„ ๊ฒ€์‚ฌํ•˜์ง€ ์•Š๊ณ  ์—ฐ์‚ฐ๋œ ๊ฐ’์˜ ์œ„์น˜๋กœ ์ด๋™ํ•˜๋Š” ๊ฒƒ์ด์ฃ .

์ด๋ž˜์„œ ๋ชจ๋“  Collision์ด Block์ž„์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ์ถฉ๋Œ์„ ๋ฌด์‹œํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๊ทธ๋Ÿฌ๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•˜๋Š๋ƒ.

Set Actor Location์˜ 2๋ฒˆ์งธ ์ธ์ž๋ฅผ true๊ฐ’์œผ๋กœ ์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

bool bSweep ์ธ์ž์— ๋Œ€ํ•œ ์„ค๋ช…์„ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

Whether we sweep to the destination location, triggering overlaps along the way and stopping short of the target if blocked by something. Only the root component is swept and checked for blocking collision, child components move without sweeping. If collision is off, this has no effect.

๋ชฉ์ ์ง€ ์œ„์น˜๋กœ ์“ธ์–ด๊ฐˆ ๊ฒƒ์ธ์ง€, ๋„์ค‘์— ์ค‘์ฒฉ์„ ๋ฐœ์ƒ์‹œํ‚ฌ ๊ฒƒ์ธ์ง€, ๋ฌด์—‡์ธ๊ฐ€์— ์˜ํ•ด ๋ง‰ํ˜”์„ ๋•Œ ๋ชฉํ‘œ๋ฌผ์— ๋„๋‹ฌํ•˜์ง€ ๋ชปํ•œ ์ฑ„ ๋ฉˆ์ถœ ๊ฒƒ์ธ์ง€ ์—ฌ๋ถ€. ๋ฃจํŠธ ๊ตฌ์„ฑ์š”์†Œ๋งŒ ์Šค์œ•๋˜์–ด ์ถฉ๋Œ ์ฐจ๋‹จ์„ ํ™•์ธํ•˜๊ณ , ํ•˜์œ„ ๊ตฌ์„ฑ์š”์†Œ๋Š” ์Šค์œ• ์—†์ด ์ด๋™ํ•ฉ๋‹ˆ๋‹ค. ์ถฉ๋Œ์ด ๊บผ์ ธ ์žˆ์œผ๋ฉด ์•„๋ฌด ํšจ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

์ด๋™ํ•  ์œ„์น˜์—์„œ ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•œ๋‹ค๋ฉด ์ด๋™ํ•˜์ง€ ์•Š๋„๋ก ํ•ด์ฃผ๋Š” ์ธ์ž์ž…๋‹ˆ๋‹ค.

์ด ๊ฐ’์„ true๋ฅผ ๋„ฃ์–ด ์ค€๋‹ค๋ฉด ์ด๋™ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

๋‹ค๋งŒ, ์ด ๊ธฐ๋Šฅ๋„ Collision์ด ๊บผ์ ธ ์žˆ๋‹ค๋ฉด ํšจ๊ณผ๊ฐ€ ์—†๋‹ค๋Š”๊ฑธ ๋ช…์‹ฌํ•ด์ฃผ์„ธ์š”.


๋งˆ๋ฌด๋ฆฌ

์›์ธ์ด ๋˜๋Š” ๊ฒƒ์€ ์™œ ๋Š˜ ๋งˆ์ง€๋ง‰์— ์ˆ˜์ •ํ•˜๊ฒŒ ๋˜๋Š” ๊ฑธ๊นŒ์š”...
์ฒ˜์Œ๋ถ€ํ„ฐ ์ž˜ ํ™•์ธํ•˜๋ฉฐ ๊ฐœ๋ฐœํ•˜๋„๋ก ํ•ฉ์‹œ๋‹ค.

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

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