ä»çµã¿ã«ã€ããŠã¯ããã©ãããã©ãŒããŒãX-Drumsãã®éçºäŸã玹ä»ããŸãã
次ã®ã¹ããŒã ã«åŸã£ãŠç§»åããŸãã
- Tiled2Unityãšã¯ã¹ããŒãã®ã»ããã¢ãã
- ã¿ã€ã«ããããšãã£ã¿ãŒã§è¡çªãæ§æãã
- Tiled2UnityããµããŒãããèšå®ãæ§æãã
- ã¿ã€ã«ããããšãã£ã¿ãŒã®èšå®ãã«ã¹ã¿ãã€ãºãã
- ã¬ã€ã€ãŒïŒãªããžã§ã¯ãïŒã®ãŠãŒã¶ãŒãã©ã¡ãŒã¿ãŒ
- ãªããžã§ã¯ãã®ã«ã¹ã¿ã ãªãã·ã§ã³
1.ãšã¯ã¹ããŒãèšå®
ãããã£ãŠãUnityã«ãããžã§ã¯ãããããTiled Map Editorã§äœæããããããããããŸãã Unityãèµ·åãã Tiled2Unity.unitypackageãã€ã³ããŒãããŸã ã
ã¿ã€ã«ããããšãã£ã¿ãŒã§ãã³ãã³ãç·šéãŠã£ã³ããŠãåŒã³åºããŸãã
å®è¡å¯èœãã¡ã€ã«Tiled2Unity.exeãžã®ãã¹ãç»é²ãããŠããæ°ããã³ãã³ããè¿œå ããŸãã 代ããã«ãïŒ mapfile Tiledã¯ãããããã¡ã€ã«ãžã®ãã¹ãèªåçã«çœ®ãæããŸãã ãã®ã³ãã³ãã®æåŸã®åŒæ°ã¯ãTiled2Unityãã©ã«ããŒãžã®ãã¹ã§ããããã¯ãã€ã³ããŒãåŸã«ãããžã§ã¯ãã«è¡šç€ºãããã¯ãã§ãã
ã³ãã³ããå®è¡ãã衚瀺ããããŠã£ã³ããŠã§å€§ããªãã¿ã³ãã¯ãªãã¯ããŸãã
ãšã¯ã¹ããŒãã®çµæãšããŠãTiled2Unityãã©ã«ããŒã«ããã«ãŒãã®ãã¬ãããååŸããŸãã ãã®ãã¬ãããUnityã®ã¹ããŒãžã«é 眮ããŸãã çŸåšãTMEã®ããããšãã®ãšã¯ã¹ããŒããæäœãããšããã·ãŒã³äžã®ãã¬ãããšãªããžã§ã¯ãã¯ãTMEã®å€æŽã«åŸã£ãŠå€æŽãããŸãã
ããã§ãTiledããUnityãžã®ãããã®ãšã¯ã¹ããŒããã»ããã¢ããããã²ãŒã ç°å¢ãäœæããŸããã
ããã§ã¯ããããäžã«ãªããžã§ã¯ããèšå®ããŸãããã
2.è¡çªãšãã£ã¿ãŒ
ãŸããããŒããŒã«ãšã£ãŠé害ãšãªãã²ãŒã 空éã®èŠçŽ ãå®çŸ©ããŸãã ãããã¯ãåºãå£ã倩äºã®ã¹ãããã©ã€ãããããŠããŒããŒããžã£ã³ããããã©ãããã©ãŒã ãšããŠæ©èœãããã©ã ã§ãã
Tiledã§ã³ãªãžã§ã³ãšãã£ã¿ãŒãèµ·åããŸãã
ãã©ã ã®äžéšãªã©ãå¿ èŠãªã¿ã€ã«ãéžæããããªãŽã³ãç·šéããŸãã
åæ§ã«ãå¿ èŠãªä»ã®ã¿ã€ã«ïŒåºãå£ãªã©ïŒãç·šéããŸãã ãã®çµæããšã¯ã¹ããŒãæã«ãTiled2Unityã¯èªåçã«PolygonCollider2Dã³ã©ã€ããŒãäœæããŸããããã¯ããŒããŒã®é害ç©ãšããŠæ©èœããŸãã
ãã ããããŒããŒã察話ã§ããä»ã®ã²ãŒã ãªããžã§ã¯ãã¯ããè€éã§ãã ã·ã³ãã«ã女æ§ãã¡ã³ãããŒããªã©ã®èŠçŽ ã®åäœã¯ãã³ã³ããŒãã³ããšã¹ã¯ãªããã䜿çšããŠå¶åŸ¡ãããŸãã ãã®ãããªãªããžã§ã¯ãããšã¯ã¹ããŒãããã«ã¯ãTiledã§è¿œå ã®ãã©ã¡ãŒã¿ãŒãæå®ããUnityã§åŠçããå¿ èŠããããŸãã
3. Tiled2UnityããµããŒããããã©ã¡ãŒã¿ãŒ
ãã ããTiled2Unityãæ¢ã«ãããè¡ã£ãŠãããããUnityã§èšå®ããã«Tiledã§äœ¿çšã§ãããã©ã¡ãŒã¿ãŒã®ãªã¹ãããããŸãã ãããã®äžã«ã¯ïŒ
å£çµïŒã¬ã€ã€ãŒ
ãŠããã£ïŒsortingLayerName å£çµïŒã¿ã° ãŠããã£ïŒsortOrder å£çµïŒisTrigger å£çµïŒç¡èŠ | Unityã®ïŒç©çïŒã¬ã€ã€ãŒå
Unityã®ãœãŒãã£ã³ã°ã¬ã€ã€ãŒã®åå Unityã®ã¿ã°ã®åå Unityã®ãã¬ã€ã€ãŒã®äžŠã¹æ¿ããå€ ã³ã©ã€ããŒãããªã¬ãŒãã©ãã ã€ã³ããŒãäžã«ã¬ã€ã€ãŒïŒãŸãã¯ãã®äžéšïŒãç¡èŠããŸãïŒå€= [false | true | collision | visual]ïŒ |
äž»äººå ¬ãé£ã³è¶ããã©ã ã¹ãã£ãã¯ã«å¿ èŠãªãã©ã¡ãŒã¿ãŒãèšå®ããŸãã
Unityã«ãšã¯ã¹ããŒããããšã次ã®çµæãåŸãããŸãã
ã¬ã€ã€ãŒã¯OneWayPlatformãã©ã¡ãŒã¿ãŒã«èšå®ãããäžããééå¯èœãªãªããžã§ã¯ãã«äœ¿çšãããŸãã
4. Tiledã®ãŠãŒã¶ãŒãªãã·ã§ã³
ä»ã®ãã©ã¡ãŒã¿ã®åŠçãèšå®ãããããããã«ã¹ã¿ã ããšåŒã³ãUnityã§ãã®ãããªãã©ã¡ãŒã¿ãæã€ãªããžã§ã¯ãããšã¯ã¹ããŒãããŸãã ã¬ã€ã€ãŒïŒãªããžã§ã¯ãïŒãšãªããžã§ã¯ãã®äž¡æ¹ã«å¯ŸããŠãã¿ã€ã«ã§èšå®ã§ããŸãã å Žåã«ãã£ãŠã¯ãæåãŸãã¯2çªç®ã®ãªãã·ã§ã³ã䟿å©ã§ãã ãããå®è£ ããæ¹æ³ãæ€èšããŠãã ããã
4.1ã ã¬ã€ã€ãŒïŒãªããžã§ã¯ãïŒã®ãŠãŒã¶ãŒãã©ã¡ãŒã¿ãŒ
ã¬ã€ã€ãŒã®ã«ã¹ã¿ã ãã©ã¡ãŒã¿ãŒãèšå®ããŸãã ãã®ãªãã·ã§ã³ã¯ãåãã¿ã€ãã®ãªããžã§ã¯ãã«äœ¿çšããŸãã ç§ãã¡ã®ã²ãŒã ã§ã¯ããããã¯ã·ã³ãã«ãšããŒãã§ãã 圌ãã®ç¹åŸŽã¯ã圌ããããŒããŒãšå¹³çã«çžäºäœçšãããäºããåºå¥ããå¿ èŠããªãããšã§ãã
Tiledã§ãªããžã§ã¯ãã®ã¬ã€ã€ãŒãäœæãããã¬ãŒããé 眮ããŸãã 次ã«ãã¬ã€ã€ãŒå šäœã«AddObjectãã©ã¡ãŒã¿ãŒãèšå®ããŸãã
åãã¬ãŒãã®ãã©ã¡ãŒã¿ãŒã®ãã£ãŒã«ãã¯ç©ºã®ãŸãŸã§ãã
次ã«ãUnityã«ç§»åããŸããããã§ã¯ããã¬ãããäœæããããŒããŒããžã£ã³ããããšãã®åäœã決å®ããã¹ã¯ãªãããããã«ãã¬ãããæ·»ä»ããŸããããŒããŒã¯èœäžããŠå ã®äœçœ®ã«æ»ããŸãã
Tiledããåãªããžã§ã¯ãã®ãã¬ãŒããã€ã³ããŒããããšãã«ããã¬ããã®ã€ã³ã¹ã¿ã³ã¹ãäœæããã³ãŒããèšè¿°ããŸãã ãããè¡ãã«ã¯ãTiled2Unity.ICustomTiledImporterã€ã³ã¿ãŒãã§ã€ã¹ãš[Tiled2Unity.CustomTiledImporter]å±æ§ãç¶æ¿ããã¯ã©ã¹ã§CustomTiledImporterForHiHatsã¹ã¯ãªãããäœæããŸãã
ãã®Tiled2Unityã¹ã¯ãªããã¯ãTiledããã€ã³ããŒããããåã¬ã€ã€ãŒãšãªããžã§ã¯ããåŒã³åºããŸãã ãããŠãããããããã©ã¡ãŒã¿ãŒã®äžã«ãHi-hatããšããå€ãæã€AddObjectãã©ã¡ãŒã¿ãŒãæã€ã¬ã€ã€ãŒãŸãã¯ãªããžã§ã¯ããåŠçãããŸãã
using System.Collections.Generic; using UnityEditor; using UnityEngine; [Tiled2Unity.CustomTiledImporter] class CustomTiledImporterForHiHats : Tiled2Unity.ICustomTiledImporter { public void HandleCustomProperties(GameObject gameObject, IDictionary<string, string> props) { if (!props.ContainsKey("AddObject")) return; if (props["AddObject"] == "Hi-hat") { // string prefabPath = "Assets/8 - Prefabs/Hi-hat.prefab"; Object obj = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)); if (obj == null) return; // , Tiled, // // List<GameObject> childrenToDestroy = new List<GameObject>(); // foreach (Transform child in gameObject.transform) { if (child.name == "TileObject") { // childrenToDestroy.Add(child.gameObject); // , GameObject objInstance = (GameObject)GameObject.Instantiate(obj); objInstance.name = obj.name; objInstance.transform.parent = gameObject.transform; objInstance.transform.position = child.transform.position; } } // childrenToDestroy.ForEach(child => GameObject.DestroyImmediate(child)); } } public void CustomizePrefab(GameObject prefab) { } }
ã¹ã¯ãªããã®æºåãå®äºãããã¬ãŒãããšã¯ã¹ããŒãã§ããŸãã
ãããŠãäž»äººå ¬ã¯åœŒããšå¯Ÿè©±ããŸãã
ããŒãã®ãšã¯ã¹ããŒãã¯ãã·ã³ãã«ã®ãšã¯ã¹ããŒããšåæ§ã«èšå®ãããŸãã å¯äžã®éãã¯ãã²ãŒã ãè²ã«å¿ããŠç°ãªãå€ãæã€ããã€ãã®ã¿ã€ãã®ããŒããæã£ãŠããããšã§ãã ãã®ãããçš®é¡ããšã®ããŒãã®çš®é¡ããšã«ãUnityã§ãã¬ãããäœæããTiledã§ãªããžã§ã¯ãã¬ã€ã€ãŒãäœæããŠãAddObjectãã©ã¡ãŒã¿ãŒã§ããŒãã®çš®é¡ã瀺ããŸããã ãã¬ããã€ã³ã¹ã¿ã³ã¹ãäœæããã€ã³ããŒãã¹ã¯ãªããã¯ãã·ã³ãã«ã¹ã¯ãªãããšåãã§ãã
4.2ã ãªããžã§ã¯ãã®ã«ã¹ã¿ã ãªãã·ã§ã³
次ã«ãåãã¿ã€ãã®ãªããžã§ã¯ãããšã¯ã¹ããŒãããæ¹æ³ãæ€èšããŸãããŠãŒã¶ãŒãã©ã¡ãŒã¿ã¯ãã¬ã€ã€ãŒã§ã¯ãªããªããžã§ã¯ãèªäœã«ãã£ãŠèšå®ãããŸãã ãã¡ã³ããã¥ãŒãããã移åãã©ãããã©ãŒã ãªã©ããã®ãããªãªããžã§ã¯ããšããŠåé¡ããŸãã åãã¿ã€ãã«ãããããããé床ãæ¹åãªã©ã®ç¬èªã®åå¥ã®ããããã£ããããŸãã
ããšãã°ããã¡ã³ã¯è²ãç°ãªããäžå®ã®è·é¢ã§ç°ãªãé床ã§åããŸãã 圌ãã¯ç¬ãããããããšãã§ããããŒããŒãšäŒããšãã圌ãã¯éžæããããã«ç¹å®ã®ææ ãåºããŸãã ãããã®ãã©ã¡ãŒã¿ãŒã¯ããªããžã§ã¯ãããšã«ã¿ã€ã«ã§èšå®ããŸãã ã¬ã€ã€ãŒã®ãç¬èªã®ãã©ã¡ãŒã¿ãŒãã¯ãããã空ã®ãŸãŸã§ãã
Unityã§ã¯ãGirlControllerã¹ã¯ãªãããæ·»ä»ãããŠãã女æ§ãã¡ã³çšã«ãã¬ãããäœæããããããããŒããŒã«å¯Ÿããè¡åãšåå¿ã決å®ããŸãã ã€ã³ããŒãã¯ãã¬ãŒãã®ã€ã³ããŒãã«äŒŒãŠããŸããããã®å Žåã¯ãã¬ããã€ã³ã¹ã¿ã³ã¹ãäœæããã ãã§ã¯äžååã§ãã GirlControllerã¹ã¯ãªããã䜿çšããŠãTiledã§åãã¡ã³ã«åå¥ã«èšå®ãããããããã£ãèšå®ããå¿ èŠããããŸãã
using System.Collections.Generic; using UnityEditor; using UnityEngine; [Tiled2Unity.CustomTiledImporter] class CustomTiledImporterForGirls : Tiled2Unity.ICustomTiledImporter { public void HandleCustomProperties(GameObject gameObject, IDictionary<string, string> props) { if (!props.ContainsKey("GirlColor")) return; // Tiled string prefabPath = "Assets/8 - Prefabs/Girls/Girl_" + props["GirlColor"] + ".prefab"; Object obj = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)); // , GameObject objInstance = (GameObject)Object.Instantiate(obj); objInstance.name = obj.name; objInstance.transform.parent = gameObject.transform.parent; objInstance.transform.position = gameObject.transform.position; objInstance.transform.localScale = gameObject.transform.localScale; objInstance.transform.eulerAngles = gameObject.transform.eulerAngles; // , // Tiled var girlController = objInstance.GetComponent<GirlController>(); if (props.ContainsKey("OffsetRight")) float.TryParse(props["OffsetRight"], out girlController.OffsetMax); if (props.ContainsKey("OffsetLeft")) float.TryParse(props["OffsetLeft"], out girlController.OffsetMin); if (props.ContainsKey("Velocity")) float.TryParse(props["Velocity"], out girlController.Velocity); if (props.ContainsKey("Stop")) float.TryParse(props["Stop"], out girlController.StopCount); if (props.ContainsKey("Fatal")) bool.TryParse(props["Fatal"], out girlController.Fatal); if (props.ContainsKey("HeartType")) { string heartPrefabPath = "Assets/8 - Prefabs/Girls/" + props["HeartType"] + ".prefab"; Object heartObj = AssetDatabase.LoadAssetAtPath(heartPrefabPath, typeof(GameObject)); girlController.heartPrefab = heartObj; } // Object.DestroyImmediate(gameObject); } public void CustomizePrefab(GameObject prefab) { } }
Unityã«ãšã¯ã¹ããŒãããTiledã§æå®ããããã©ã¡ãŒã¿ãŒãGirlControllerã¹ã¯ãªããå€æ°ã«ãã£ãŠèšå®ãããããšã確èªããŸãã
ä»ã®ã°ã«ãŒãã®ãªããžã§ã¯ãã«ã€ããŠèª¬æããã¹ããŒã ãç¹°ãè¿ããUnityã«ãšã¯ã¹ããŒããããšãã«ãã²ãŒã ã®ã»ãšãã©ã®ã³ã³ããŒãã³ãã®æ§ææžã¿ãã¬ãããååŸããŸãã
説æããã¢ãããŒãã¯ããã©ãããã©ãŒããŒãäœæããããã«äœ¿çšãããŸããã ãã®ç¹å®ã®ã²ãŒã ã§ã¯ãTiled Map Editorããã³Unityãšé£æºããŠäœæ¥ããããšã«ãããäœæããã»ã¹ãå éãããTMEã®ã¬ãã«ãã¶ã€ããŒãšUnityã®ããã°ã©ããŒã®äž¡æ¹ãäºãã«å¹²æžããããšãªãåæã«äœæ¥ã§ããããã«ãªããŸããã ç§ãã¡ã®ãããªãããžã§ã¯ãã§ã¯ãTiled2UnityãŠãŒãã£ãªãã£ã¯éåžžã«äŸ¿å©ã§ãããèšäºã«åºã¥ããŠãã²ãŒã éçºã§ä»»æã®ãªãã·ã§ã³ã䜿çšã§ããŸãã