1 of 14

Unity物理エンジンの2Dゲームにおける応用

Unity 物理 完全に理解した 勉強会

2026/06/19

lufy

2 of 14

本日話したいこと

簡単な Mario-like ゲーム紹介

目的

  • Unity 2D Physics の基本を理解する
  • キャラクター移動
  • ジャンプ
  • 当たり判定
  • Trigger Enemy AI

3 of 14

4 of 14

ゲーム構成

5 of 14

Rigidbody2D 和 Collider2D

  • Rigidbody2D : 重力と移動
  • Collider2D : 当たり判定

6 of 14

Ground

  • Static Collider

7 of 14

プレイヤー移動

  • PlayerController2D.cs

rb.linearVelocity = new Vector2(

inputX * moveSpeed,

rb.linearVelocity.y

);

8 of 14

ジャンプ

  • GroundCheck
  • Physics2D.OverlapCircle()

9 of 14

敵の移動

  • Physics2D.Raycast()

10 of 14

敵を踏める

  • contact.normal.y > 0.5f

11 of 14

コイン

  • Trigger
  • OnTriggerEnter2D()

12 of 14

Question Block

  • contact.normal.y > 0.5f
  • Instantiate()

13 of 14

Unity実機デモ

14 of 14

まとめ

  • Unity Physics を使うことで、少ないコードで Platformer を実装できる

https://github.com/lufylegend/mario-like

ありがとうございました