Unity 미니풋볼
발행: (2025년 12월 11일 오전 02:47 GMT+9)
6 min read
원문: Dev.to
Source: Dev.to
1. 필드 평면 (Plane)
- Hierarchy → Right‑click → 3D Object → Plane
- Inspector settings:
- Name:
Ground - Position: X = 0, Y = 0, Z = 0
- Scale: X = 2, Y = 1, Z = 3
- Name:
2. 녹색 재질 만들기
- Project → Right‑click → Create → Material
- Name:
GrassMaterial - Inspector → Albedo: choose green
#2D7A2F - Drag & drop the material onto the Ground object.
✅ 결과: 녹색 축구장이 준비되었습니다!
3. 벽 만들기
3.1 왼쪽 벽
- Hierarchy → Right‑click → 3D Object → Cube
- Inspector:
- Name:
WallLeft - Position: X = ‑10, Y = 0.5, Z = 0
- Scale: X = 0.2, Y = 1, Z = 30
- Name:
3.2 오른쪽 벽
- Hierarchy → Right‑click → 3D Object → Cube
- Inspector:
- Name:
WallRight - Position: X = 10, Y = 0.5, Z = 0
- Scale: X = 0.2, Y = 1, Z = 30
- Name:
3.3 뒷벽 (플레이어 쪽)
- Create Cube → Name:
WallBack - Position: X = 0, Y = 0.5, Z = ‑15
- Scale: X = 20, Y = 1, Z = 0.2
3.4 앞벽 (상대 쪽)
- Create Cube → Name:
WallFront - Position: X = 0, Y = 0.5, Z = 15
- Scale: X = 20, Y = 1, Z = 0.2
3.5 벽 재질
- Create → Material → Name:
WallMaterial - Albedo: choose gray or red
- Apply the material to all four walls.
✅ 결과: 4개의 벽으로 둘러싸인 필드가 완성되었습니다!
4. 공 만들기
4.1 공 오브젝트
- Hierarchy → 3D Object → Sphere
- Inspector:
- Name:
Ball - Position: X = 0, Y = 0.5, Z = 0
- Scale: X = 0.5, Y = 0.5, Z = 0.5
- Name:
4.2 공 재질
- Create → Material → Name:
BallMaterial - Albedo: white
- Apply to the Ball object.
4.3 물리 추가
- Select Ball → Inspector → Add Component → Rigidbody
- Rigidbody settings:
- Mass: 0.5
- Drag: 0.5
- Angular Drag: 0.5
- Use Gravity: ✅
4.4 공용 물리 재질
- Project → Create → Physics Material → Name:
BallPhysics - Inspector:
- Dynamic Friction: 0.6
- Static Friction: 0.6
- Bounciness: 0.3
- Friction Combine: Average
- Bounce Combine: Average
- Select Ball → Rigidbody → Material → assign BallPhysics.
5. 플레이어 (캡슐) 만들기
5.1 플레이어 오브젝트 추가
- Hierarchy → 3D Object → Capsule
- Inspector:
- Name:
Player - Position: X = 0, Y = 1, Z = ‑10
- Scale: X = 1, Y = 1, Z = 1
- Name:
5.2 플레이어 재질
- Create → Material → Name:
PlayerMaterial - Albedo: blue
#0066FF - Apply to the Player object.
5.3 물리 추가
- Select Player → Add Component → Rigidbody
- Rigidbody settings:
- Mass: 2
- Drag: 2
- Angular Drag: 5
- Use Gravity: ✅
- Constraints: Freeze Rotation on X, Y, Z.
5.4 캡슐 콜라이더 설정
- The Player already has a Capsule Collider.
- Radius: 0.5
- Height: 2
✅ 결과: 파란색 플레이어가 준비되었습니다!
6. 태그 추가
6.1 공 태그
- Select the Ball object.
- In the Inspector, click the Tag dropdown → Add Tag… → + → Name:
Ball. - Save, then re‑select Ball and set its Tag to
Ball.
6.2 플레이어 태그
- Select Player, set Tag to
Player. - If the tag does not exist, create it via Add Tag… → Name:
Player.
7. 카메라 설정
- Select Main Camera.
- Transform:
- Position: X = 0, Y = 15, Z = ‑12
7.1 카메라 스크립트 (CameraFollow)
- Drag the
CameraFollowscript onto Main Camera. - In the script component:
- Target: drag the Player object.
- Offset: X = 0, Y = 15, Z = ‑12
- Smooth Speed: 5
8. 골대 만들기
8.1 플레이어 골대 (아래쪽)
- Hierarchy → Create Empty → Name:
GoalPlayer - Position: X = 0, Y = 0, Z = ‑14
Inside GoalPlayer, create three Cube objects and assign a material:
- Create → Material → Name:
GoalPostMaterial→ Albedo: white - Apply the material to all three cubes.
8.2 AI 골대 (위쪽)
- Duplicate GoalPlayer (Ctrl + D).
- Rename:
GoalAI - Position: X = 0, Y = 0, Z = 14
✅ 결과: 2개의 골대가 준비되었습니다!
9. 골 트리거 만들기
9.1 플레이어용 트리거
- Select GoalPlayer → Right‑click → 3D Object → Cube
- Name:
GoalTriggerPlayer - Position: X = 0, Y = 1, Z = 0.5
- Scale: X = 6, Y = 2, Z = 0.5
Trigger 설정:
- Add Box Collider → enable Is Trigger.
- Disable Mesh Renderer (make it invisible).
9.2 AI용 트리거
- Copy GoalTriggerPlayer (Ctrl + C).
- Select GoalAI, paste as child (Ctrl + V).
- Rename:
GoalTriggerAI - Position: X = 0, Y = 1, Z = ‑0.5
9.3 태그 추가
- Create tags
GoalPlayerandGoalAI(if they don’t exist). - Assign
GoalPlayertag to GoalTriggerPlayer andGoalAItag to GoalTriggerAI.
10. 골 시스템 스크립트
// GoalDetector.cs
using UnityEngine;
public class GoalDetector : MonoBehaviour
{
private GameManager gameManager;
void Start()
{
gameManager = FindObjectOfType();
}
// Add trigger handling logic here...
}
- Attach GoalDetector to GoalTriggerPlayer and set Is Player Goal to ✅.
- Attach another GoalDetector to GoalTriggerAI and leave Is Player Goal unchecked.
11. 게임 매니저 (점수 시스템)
// GameManager.cs
using UnityEngine;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public Text playerScoreText;
public Text aiScoreText;
public GameObject ball;
// Implement scoring logic here...
}
- Create an empty GameObject named
GameManager. - Drag the
GameManager.csscript onto it.
12. UI 만들기 (점수 표시)
12.1 캔버스 설정
- Render Mode: Screen Space – Overlay
- Canvas Scaler → UI Scale Mode: Scale With Screen Size
- Reference Resolution: 1920 × 1080
12.2 플레이어 점수 (좌상단)
- Canvas → Right‑click → UI → Text → Name:
PlayerScoreText - Rect Transform:
- Anchor: Top‑Left
- Pos X: 100, Pos Y: ‑50
- Width: 200, Height: 100
- Text component:
- Text:
0 - Font Size: 72
- Alignment: Center
- Color: blue
- Text:
12.3 AI 점수 (우상단)
- Canvas → Right‑click → UI → Text → Name:
AIScoreText - Rect Transform:
- Anchor: Top‑Right
- Pos X: ‑100, Pos Y: ‑50
- Width: 200, Height: 100
- Text component:
- Text:
0 - Font Size: 72
- Alignment: Center
- Color: red
- Text:
12.4 GameManager에 UI 연결
- Select GameManager → in the Inspector assign:
- Player Score Text: drag
PlayerScoreText - AI Score Text: drag
AIScoreText - Ball: drag the Ball object
- Player Score Text: drag
✅ 테스트:
- 골이 들어가면 점수가 증가하나요? ✅
- 공이 중앙으로 되돌아오나요? ✅
- 점수가 화면에 표시되나요? ✅
13. 씬 저장
- File → Save As… → give the scene an appropriate name (e.g.,
GameScene).
14. 메인 메뉴 씬 만들기
14.1 새 씬
- File → New Scene
14.2 UI 추가
- Hierarchy → Right‑click → UI → Canvas
14.3 버튼
- Inside the Canvas: Right‑click → UI → Button - TextMeshPro (create START, EXIT, etc.).
14.4 MenuManager 스크립트
- Add a
MenuManagerscript to the Canvas and configure the buttons (START → load game scene, EXIT → quit application).
15. 빌드 설정
- File → Build Settings (Ctrl + Shift + B)
- Add scenes in order:
MainMenu(index 0)GameScene(index 1)
✅ 테스트: MainMenu 씬에서 게임을 실행해 보세요.
16. 일시 정지 메뉴
16.1 일시 정지 UI
- Open GameScene → Hierarchy → Right‑click → UI → Canvas
- Inside the Canvas, add a Panel (name it
PausePanel). - Add Button objects under
PausePanel(e.g., RESUME, MENU, RESTART).
16.2 PausePanel 숨기기
- Select
PausePaneland disable it by default (uncheck the GameObject).