1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Unityでつくる2DRPG ~⑪敵のデータを作成

Last updated at Posted at 2025-12-24

はじめに

前回は、魔法データを作成しました。

今回は、似たような方法で敵のデータを作成します。

スクリプトの作成

スクリプトを新規作成し、名前を「EnemyData」としてください。
その後、以下のスクリプトをコピペしてください。

//EnemyData.cs
using System.Collections.Generic;
using UnityEngine;

public enum Element { None, Fire, Water, Ice, Wind, Thunder, Light, Dark }

[CreateAssetMenu(menuName = "RPG/EnemyData")]
public class EnemyData : ScriptableObject
{
    public string enemyName = "Enemy";
    public int maxHP = 10;
    public int maxMP = 0;
    public int speed = 5;
    public int atk = 3;
    public int def = 1;
    public int matk = 0;
    public int mdef = 0;
    public Element attribute = Element.None;
    public int giveExp = 5;
    public int giveMoney = 10;

    public List<MagicData> learnedMagic = new List<MagicData>();

    [Header("Portrait")]
    public Sprite portraitSprite;
}

また、MagicDataの以下のコメントアウト部分について、//を削除してください。

 //   public Element attribute = Element.Fire;

敵のデータの作成

プロジェクトタブ上で右クリックし、
Create → RPG → EnemyData
で敵のデータを作成できます。
image.png

ざっくりとパラメータについて解説します。
・Enemy Name ~ 敵の名前
・Give Exp ~ 戦闘勝利時にもらえる経験値
・Give Money ~ 戦闘勝利時にもらえるお金
・Portrait Sprite ~ 戦闘時に表示される立ち絵

Portrati Spriteには、お好みの画像をアタッチしておいてください。

おわり

今回は、敵のデータを作成しました。

次回は、戦闘システムの構築に入ります。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?