好感度システムは、恋愛シミュレーションの核心です。
数値で関係性を管理し、会話やイベントに反映します。
この記事では、実装方法を詳しく解説します。
✨ この記事でわかること
- 好感度データの構造
- 好感度の増減ロジック
- 閾値によるイベント発生
- 会話への反映方法
- 実装例とコード

好感度システムは、数値の増減が核心です。選択肢に応じて、適切に好感度を変化させましょう。
Unity入門の森を見る 初心者歓迎!動画×プロジェクト一式で本格ゲーム制作を学べる
あなたのオリジナルゲーム、今年こそ完成させませんか?
RPG・アクション・ホラー…Unityで本格ゲームを作りたい人のための学習サイトです。
実際に完成するゲームを題材に、
ソースコード・素材・プロジェクト一式をすべて公開。
仕事や学校の合間の1〜2時間でも、
「写経→改造」で自分のゲームまで作りきれる環境です。
好感度データの構造

好感度データは、キャラクターごとに管理します。
実装方法を紹介します。
好感度データの実装
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
using UnityEngine; using System.Collections.Generic; [System.Serializable] public class AffectionData { public string characterName; public int affection = 0; // 好感度(0〜100) public int trust = 0; // 信頼度(0〜100) public int intimacy = 0; // 親密度(0〜100) [Header("関係性レベル")] public RelationshipLevel relationshipLevel = RelationshipLevel.Stranger; public void UpdateRelationshipLevel() { int total = affection + trust + intimacy; if (total >= 240) // 80% × 3 { relationshipLevel = RelationshipLevel.Lover; } else if (total >= 180) // 60% × 3 { relationshipLevel = RelationshipLevel.Close; } else if (total >= 120) // 40% × 3 { relationshipLevel = RelationshipLevel.Friend; } else if (total >= 60) // 20% × 3 { relationshipLevel = RelationshipLevel.Acquaintance; } else { relationshipLevel = RelationshipLevel.Stranger; } } } public enum RelationshipLevel { Stranger, // 見知らぬ人 Acquaintance, // 知り合い Friend, // 友人 Close, // 親しい Lover // 恋人 } public class AffectionManager : MonoBehaviour { private Dictionary<string, AffectionData> affectionData = new Dictionary<string, AffectionData>(); public void InitializeCharacter(string characterName) { if (!affectionData.ContainsKey(characterName)) { affectionData[characterName] = new AffectionData { characterName = characterName }; } } public AffectionData GetAffectionData(string characterName) { if (!affectionData.ContainsKey(characterName)) { InitializeCharacter(characterName); } return affectionData[characterName]; } } |
このコードで、好感度データの基本構造が実装できます。
キャラクターごとに、好感度、信頼度、親密度を管理します。
Unity入門の森を見る 初心者歓迎!動画×プロジェクト一式で本格ゲーム制作を学べる
好感度の増減ロジック

好感度の増減は、選択肢に応じて変化します。
実装方法を紹介します。
好感度変化の実装
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
public class AffectionChangeSystem : MonoBehaviour { public AffectionManager affectionManager; public void ChangeAffection(string characterName, AffectionChange change) { AffectionData data = affectionManager.GetAffectionData(characterName); // 好感度を変更 data.affection = Mathf.Clamp(data.affection + change.affectionChange, 0, 100); data.trust = Mathf.Clamp(data.trust + change.trustChange, 0, 100); data.intimacy = Mathf.Clamp(data.intimacy + change.intimacyChange, 0, 100); // 関係性レベルを更新 data.UpdateRelationshipLevel(); // 関係性レベルが変わった場合の処理 CheckRelationshipLevelChange(characterName, data); } void CheckRelationshipLevelChange(string characterName, AffectionData data) { // 関係性レベルが変わった場合のイベント // 実装は省略 } } [System.Serializable] public class AffectionChange { public int affectionChange = 0; public int trustChange = 0; public int intimacyChange = 0; public AffectionChange(int affection, int trust, int intimacy) { affectionChange = affection; trustChange = trust; intimacyChange = intimacy; } } |
このコードで、好感度の増減が実装できます。
選択肢に応じて、好感度、信頼度、親密度が変化します。
選択肢による好感度変化の例
✅ 選択肢による好感度変化の例
- 良い選択肢:好感度+5、信頼度+3
- 普通の選択肢:好感度+1、信頼度+1
- 悪い選択肢:好感度-3、信頼度-2
選択肢の種類に応じて、好感度の変化量を変えます。

好感度の変化量は、小さく設定しましょう。一度に大きく変えると、バランスが崩れます。+5程度が標準です。
Unity入門の森を見る 初心者歓迎!動画×プロジェクト一式で本格ゲーム制作を学べる
閾値によるイベント発生

閾値に達すると、特別なイベントが発生します。
実装方法を紹介します。
閾値イベントの実装
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
using UnityEngine; using System.Collections.Generic; [System.Serializable] public class AffectionThreshold { public int threshold = 50; public string eventID; public bool hasTriggered = false; } public class AffectionEventSystem : MonoBehaviour { public AffectionManager affectionManager; public List<AffectionThreshold> thresholds = new List<AffectionThreshold>(); public void CheckAffectionThresholds(string characterName) { AffectionData data = affectionManager.GetAffectionData(characterName); foreach (var threshold in thresholds) { if (!threshold.hasTriggered && data.affection >= threshold.threshold) { TriggerThresholdEvent(characterName, threshold); threshold.hasTriggered = true; } } } void TriggerThresholdEvent(string characterName, AffectionThreshold threshold) { Debug.Log($"{characterName}の好感度が{threshold.threshold}に達しました!"); // イベントを発生 // 実装は省略 } } |
このコードで、閾値イベントが実装できます。
好感度が閾値に達すると、特別なイベントが発生します。
閾値の設定例
- 20:初めて会話できる
- 40:一緒に行動できる
- 60:特別なイベントが発生
- 80:告白イベントが発生
- 100:恋人関係になる
閾値を段階的に設定すれば、関係性の進展が明確になります。
Unity入門の森を見る 初心者歓迎!動画×プロジェクト一式で本格ゲーム制作を学べる
会話への反映方法

好感度に応じて、会話の内容が変わります。
実装方法を紹介します。
会話分岐の実装
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
[System.Serializable] public class DialogueLine { public string dialogueText; public AffectionCondition condition; } [System.Serializable] public class AffectionCondition { public int minAffection = 0; public int maxAffection = 100; public RelationshipLevel minLevel = RelationshipLevel.Stranger; } public class DialogueSystem : MonoBehaviour { public AffectionManager affectionManager; public string GetDialogue(string characterName, List<DialogueLine> dialogueLines) { AffectionData data = affectionManager.GetAffectionData(characterName); // 条件を満たす会話を探す foreach (var line in dialogueLines) { if (CheckAffectionCondition(data, line.condition)) { return line.dialogueText; } } // デフォルトの会話 return dialogueLines[0].dialogueText; } bool CheckAffectionCondition(AffectionData data, AffectionCondition condition) { if (data.affection < condition.minAffection) return false; if (data.affection > condition.maxAffection) return false; if (data.relationshipLevel < condition.minLevel) return false; return true; } } |
このコードで、好感度に応じた会話分岐が実装できます。
好感度と関係性レベルに応じて、会話の内容が変わります。
Unity入門の森を見る 初心者歓迎!動画×プロジェクト一式で本格ゲーム制作を学べる
実装例:完全な好感度システム

実際に使える、完全な好感度システムの実装例を紹介します。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
using UnityEngine; public class CompleteAffectionSystem : MonoBehaviour { [Header("システム")] public AffectionManager affectionManager; public AffectionChangeSystem changeSystem; public AffectionEventSystem eventSystem; public DialogueSystem dialogueSystem; public void OnChoiceSelected(string characterName, AffectionChange change) { // 好感度を変更 changeSystem.ChangeAffection(characterName, change); // 閾値イベントをチェック eventSystem.CheckAffectionThresholds(characterName); } public string GetDialogue(string characterName, List<DialogueLine> dialogueLines) { return dialogueSystem.GetDialogue(characterName, dialogueLines); } } |
このコードで、完全な好感度システムが実装できます。
好感度管理、増減ロジック、閾値イベント、会話分岐を統合しています。
Unity入門の森を見る 初心者歓迎!動画×プロジェクト一式で本格ゲーム制作を学べる
よくある質問(FAQ)

Unity入門の森を見る 初心者歓迎!動画×プロジェクト一式で本格ゲーム制作を学べる
あなたのオリジナルゲーム、今年こそ完成させませんか?
RPG・アクション・ホラー…Unityで本格ゲームを作りたい人のための学習サイトです。
実際に完成するゲームを題材に、
ソースコード・素材・プロジェクト一式をすべて公開。
仕事や学校の合間の1〜2時間でも、
「写経→改造」で自分のゲームまで作りきれる環境です。
まとめ

好感度システムは、数値の増減が核心です。
閾値と会話分岐を組み合わせれば、自然な関係性の変化が実現できます。
✅ 今日から始める3ステップ
- ステップ1:好感度データ構造を実装する(所要1時間)
- ステップ2:好感度の増減ロジックを実装する(所要2時間)
- ステップ3:閾値イベントシステムを実装する(所要2時間)
本格的にUnityを学びたい方は、Unity入門の森で実践的なスキルを身につけましょう。
あなたのペースで、少しずつ進めていけば大丈夫です。
Unity入門の森を見る 初心者歓迎!動画×プロジェクト一式で本格ゲーム制作を学べる



コメント