{"_id":"59a9f7b328ab5f000f239558","category":{"_id":"59a9f7b328ab5f000f239550","version":"59a9f7b328ab5f000f23954a","project":"543b9b0065bf840e00b473d5","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-03-19T04:10:22.740Z","from_sync":false,"order":5,"slug":"units","title":"Units"},"user":"543b9aa865bf840e00b473d1","parentDoc":null,"project":"543b9b0065bf840e00b473d5","version":{"_id":"59a9f7b328ab5f000f23954a","project":"543b9b0065bf840e00b473d5","__v":1,"createdAt":"2017-09-02T00:13:39.834Z","releaseDate":"2017-09-02T00:13:39.834Z","categories":["59a9f7b328ab5f000f23954b","59a9f7b328ab5f000f23954c","59a9f7b328ab5f000f23954d","59a9f7b328ab5f000f23954e","59a9f7b328ab5f000f23954f","59a9f7b328ab5f000f239550","59a9f7b328ab5f000f239551","59a9f7b328ab5f000f239552","59a9f7b328ab5f000f239553","59a9f7b328ab5f000f239554","59a9f7b328ab5f000f239555","59a9f7b328ab5f000f239556","59a9f7b328ab5f000f239557"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"7.2.0","version":"7.2"},"githubsync":"","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-03T18:25:58.942Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Reminder - Keep Daily Backups\",\n  \"body\": \"When working on a strategy game with a kit as big as the Complete Kit - always keep a working daily backup! Save yourself the trouble of rolling-back changes and losing work.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"What are unit prefabs?\"\n}\n[/block]\nEvery character in your game needs to be setup as a prefab. We've got 7 examples already setup in the game for you, they are as follows:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Unit\",\n    \"h-1\": \"Prefab\",\n    \"0-0\": \"Alien\",\n    \"1-0\": \"Handyman\",\n    \"2-0\": \"Dobbit\",\n    \"3-0\": \"Viking\",\n    \"4-0\": \"Hydra\",\n    \"5-0\": \"Mage\",\n    \"6-0\": \"Archer\",\n    \"0-1\": \"Alien.prefab\",\n    \"1-1\": \"HandyMan.prefab\",\n    \"6-1\": \"Archer.prefab\",\n    \"2-1\": \"Dobbit.prefab (Hometown NPC)/DobbitSoldier.prefab (Army Battle)\",\n    \"4-1\": \"Hydra.prefab\",\n    \"5-1\": \"Mage.prefab\",\n    \"3-1\": \"Viking.prefab\"\n  },\n  \"cols\": 2,\n  \"rows\": 7\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Create Your Own Unit Prefab Video Demo\"\n}\n[/block]\nThe following video demo explains how to create your unit prefabs. We use the Alien unit files which are available for download in the CityBuildingKit.com download center.\n[block:embed]\n{\n  \"html\": \"<iframe class=\\\"embedly-embed\\\" src=\\\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F4NuBGtYCaXw%3Ffeature%3Doembed&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D4NuBGtYCaXw%26feature%3Dyoutu.be&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F4NuBGtYCaXw%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\\\" width=\\\"854\\\" height=\\\"480\\\" scrolling=\\\"no\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\",\n  \"url\": \"https://www.youtube.com/watch?v=4NuBGtYCaXw&feature=youtu.be\",\n  \"title\": \"Adding Unit - Tutorial #4\",\n  \"favicon\": \"https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico\",\n  \"image\": \"https://i.ytimg.com/vi/4NuBGtYCaXw/hqdefault.jpg\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Getting Started...\"\n}\n[/block]\nBefore adding new characters, take a look at how our example character is structured.\n\nFirst, you will need sprite sheets for the new characters. These are either hand-drawn, or 3D renders from different angles with the character walking or performing different tasks. Our sprite sheets are in Sprites_TK2D (Assets\\Sprites_TK2D\\Units\\Dobbit\\walk).\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/iw5Pz6weQqS8ArYVQ6lK_spritesheet6.jpg\",\n        \"spritesheet6.jpg\",\n        \"800\",\n        \"600\",\n        \"#78555b\",\n        \"\"\n      ],\n      \"caption\": \"Click on image to view larger. Assets\\\\Sprites_TK2D\\\\Units\\\\Dobbit\\\\walk sprite sheet\"\n    }\n  ]\n}\n[/block]\nHere is a great tutorial from Digital Tutors for creating the sprite sheets:\n[block:html]\n{\n  \"html\": \"<iframe width=\\\"560\\\" height=\\\"315\\\" src=\\\"https://www.youtube.com/embed/cRE2G96591E?rel=0&amp;showinfo=0\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\"\n}\n[/block]\nWe use a software called [Texture Packer](https://www.codeandweb.com/texturepacker) and we talk about how to get setup with it on the next doc.\nThen, you will need to create 2D Toolkit sprite collections and sprite animations. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Assets\\\\SpriteCollections_TK2D\\\\Units\\\\Animated\\\\Dobbit\\\\HIQ\\n\\tHIQ_dobbit_walk\\n\\tHIQ_dobbit_walk_animation\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nCopy the sprite sheet in Assets\\Sprites_TK2D\\Units\\<Name of character> Folder\n\nCreate a new folder in Assets\\SpriteCollections_TK2D\\Units\\Animated\\<Folder with same name>. Create new sprite collections and rename them <name>Idle, <name>Shoot, <name>Walk to keep things organized – due to the high number of frames (not recommended), we had to split the sprite collections.\n\nOpen one, create 8 empty sprite sheets and drag the appropriate images, into the Texture slot. Press **Setup** for each as you drag each in.\n\nFill in the individual sprite Width / Height, Pad Black Zero Alpha and press Apply. This will separate the sprite sheet into individual sprites\nfor the atlas. Delete the last empty sprites(if any).\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/wWlBBG2vSCuCowzB4yXV_sprite-sheet1.jpg\",\n        \"sprite-sheet1.jpg\",\n        \"800\",\n        \"600\",\n        \"#607896\",\n        \"\"\n      ],\n      \"caption\": \"Click on image to view larger. Individual animation frames with 2D Toolkit\"\n    }\n  ]\n}\n[/block]\nWe have split our collections based on actions (walk, idle, etc), but you can basically insert all sprite sheets/animations into one collection/animation, provided that the size of the resulting atlas image doesn't exceed the maximum allowed dimension. \n\nTo make best use of the image atlas, you can dice each frame. Select all sprites, Render Mesh Diced, Apply to dice all sprites and hit **Commit** to create the Sprite Collection.\n[block:image]\n{\n  \"images\": [\n    {\n      \"caption\": \"Click on image to view larger. Diced frame example\",\n      \"image\": [\n        \"https://files.readme.io/pKLDB2m0TOm9uGtF607x_sprite-sheet2.jpg\",\n        \"sprite-sheet2.jpg\",\n        \"800\",\n        \"600\",\n        \"#805260\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nThe frames are diced for better use of the sprite collection texture.\n[block:image]\n{\n  \"images\": [\n    {\n      \"caption\": \"Click on image to view larger. Diced Atlas Image\",\n      \"image\": [\n        \"https://files.readme.io/c70oao5Su6LwRPn8Dbo2_spritesheet3.jpg\",\n        \"spritesheet3.jpg\",\n        \"800\",\n        \"600\",\n        \"#648cbc\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nThen, take a look at our soldier prefab (Assets\\Prefabs\\Creators\\Units\\DobbitSoldier.prefab).\n\nBased on how our simple dobbit animation controller is configured, you will need 3 separate sprite animations, for Idle, Attack and Walk.\nThe clips inside are called Idle_ or Attack_ or Walk_ + direction – N,S,E,W, NE,NW,SE,SW (North, South, etc)\n\nThe basic components of an animated character are a 2D Toolkit Sprite and a Sprite Animator. Then, a series of controllers, the animation controller and other elements that make the character walk, change direction, attack, etc.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"How to test animated units that I import?\"\n}\n[/block]\nIn the Scripts/Units/AnimController.cs Update() function there is a commented paragraph for manually testing animation/direction of units. Below is an excerpt.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Scripts/Units/AnimController.cs\\n// Function is commented out, but this will allow you to \\n// Manually control units and test them with key presses\\n// Movement keys: F R E W S X C\\n// Animation Keys: I O K L\\n//\\nvoid Update () {\\n\\n\\t//Manual controller to check animations\\n\\t/*\\n\\tbool animChanged = false;\\n\\tif(Input.anyKey){ animChanged = true; }\\n\\n\\tif(Input.GetKey(KeyCode.F)){ direction = \\\"E\\\"; }\\n\\telse if(Input.GetKey(KeyCode.R)){ direction = \\\"NE\\\"; }\\n\\telse if(Input.GetKey(KeyCode.E)){ direction = \\\"N\\\"; }\\n\\telse if(Input.GetKey(KeyCode.W)){ direction = \\\"NW\\\"; }\\n\\telse if(Input.GetKey(KeyCode.S)){ direction = \\\"W\\\"; }\\n\\telse if(Input.GetKey(KeyCode.Z)){ direction = \\\"SW\\\"; }\\n\\telse if(Input.GetKey(KeyCode.X)){ direction = \\\"S\\\"; }\\n\\telse if(Input.GetKey(KeyCode.C)){ direction = \\\"SE\\\"; }\\t\\t\\n\\n\\tif(Input.GetKey(KeyCode.I)){action = \\\"Idle\\\"; animator.Library = idleAnimation;\\t\\t}\\n\\telse if(Input.GetKey(KeyCode.O)){action = \\\"Walk\\\"; animator.Library = walkAnimation;\\t\\t}\\n\\telse if(Input.GetKey(KeyCode.K)){action = \\\"Attack\\\"; animator.Library = attackAnimation;\\t\\t}\\n\\telse if(Input.GetKey(KeyCode.L)){action = \\\"Build\\\"; animator.Library = buildAnimation;\\t\\t}\\n\\n\\tif(animChanged){UpdateCharacterAnimation();}\\n\\t*/\\n}\",\n      \"language\": \"csharp\",\n      \"name\": \"Scripts/Units/AnimController.cs Update() Function\"\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"caption\": \"Click on image to view larger. Manually Testing Your Character\",\n      \"image\": [\n        \"https://files.readme.io/VGoIeuYbQkieDL5s9FAp_spritesheet4.jpg\",\n        \"spritesheet4.jpg\",\n        \"800\",\n        \"600\",\n        \"#3e7ea8\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nAt the time of this writing, there are seven animated characters in our kit as listed in the chart above. Study how these examples work. \n\nFor NPC demonstrations, look at how the Construction Dobbit follows a fixed path around construction objects, while the soldier dobbit prefab is much more versatile for battle.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"How do I setup my XML?\"\n}\n[/block]\nNow, we need to update the units.xml file. This is pretty simple to do, since all you're editing here is the name and description plus prices and time. Settings that are imported by the game and aren't too critical.\n\nThere's only one thing to remember - keep the same order in the XML as your prefab order in Unity.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"**Always keep the same order in all menus/XML files for all structures or units.**\\n\\nThe order in the XML file must match the order of units in the store. The first 5 units (starting with the Alien) appear on the top and the last 5 units (starting with the Mage) appear on the bottom of the menu. If you've changed the units in your UIAnchor ArmyMenu, this order must be the same in your XML or else things will get mixed up.\\n\\nAlso, later in documentation page Part 2: Update Units Menus the order of elements in the Inspector prefab array must match the same order you've used in the XML or else you'll find units get accidentally mixed up.\",\n  \"title\": \"XML Order Must Match Prefab Order in Unity\"\n}\n[/block]\nThe following is a sample of the first XML item in the document, which matches the first prefab in Unity.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\t<Unit>\\t\\t\\t\\n\\t\\t<Name>Green Alien</Name>\\n    <!--  name displayed in the store -->\\t\\t\\t\\n    \\n\\t\\t<UnitType>Alien</UnitType>\\n    <!--  IMPORTANT: this same as prefab - instead of clutting the labels list you set the prefab name here in the XML. Prettier right? -->\\t\\n    \\n\\t\\t<Description>A smelly alien, green with envy. Maybe it's something he ate?</Description>\\n    <!--  description displayed in the store -->\\t\\n\\n\\t\\t<Currency>Mana</Currency>\\n    <!-- either Gold, Mana, or Crystals to buy -->\\t\\t\\n    \\n\\t\\t<Price>50</Price>\\n    <!-- amount of resource necessary to pay for the unit-->\\n    \\n\\t\\t<TimeToBuild>1</TimeToBuild>\\n    <!-- the time (in minutes) needed to create the unit -->\\n\\n\\t\\t<Life>200</Life>\\n    <!-- HP of this unit -->\\n    \\n\\t\\t<Size>1</Size>\\n    <!--how many population slots the unit occupies-->\\n    <!--by default it is 1, but you can increase this like 3, 5, 10, etc. -->\\n\\n\\t\\t<XpAward>100</XpAward>\\n    <!-- experience awarded for the completion of an object -->\\n\\t</Unit>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Where do I instantiate my units?\"\n}\n[/block]\nUnits are instantiated in Scripts/Menus/Army/MenuArmyBattle.cs in the InstantiateUnit() function. This has different cases for each of the units you've setup in your XML/units.xml file that prefills the store with your units.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"**Make sure the index here matches your XML/units.xml file part-for-part.**\\n\\nFor example, \\\"Unit\\\" or \\\"Dobbit\\\" or \\\"Soldier\\\" tag applies to all units, and is used for target identification. The kit uses the default \\\"Dobbit\\\" tag for all units but for ease of understanding, it should actually be changed to \\\"Unit\\\" as we've written in the below examples.\"\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/83ebd81-tag.jpg\",\n        \"tag.jpg\",\n        1366,\n        742,\n        \"#c4c4c3\"\n      ],\n      \"caption\": \"The kit uses the default \\\"Dobbit\\\" tag for all unit. Click to view larger.\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Scripts/Menus/Army/MenuArmyBattle.cs\\n// The following function is triggered after a unit is deployed\\n// in battle. The cases are included for the characters\\n// \\n// Depending on which unit is clicked in the menu\\n// It will send the game object tag to ProcessUnit()\\n// Which loads the correct game object. If no object exists\\n// ProcessUnit() will default with the dobbit (builder/farmer) character\\n// As of this time, the values carried\\n//\\n\\tprivate void InstantiateUnit(int index, float speedModifier)\\n\\t{\\n\\t\\tswitch (index) \\n\\t\\t{\\n\\t\\tcase 0:\\n        // Instantiates the first UnitPrefab (Element 0) from the array\\n\\t\\t\\tGameObject Wizard = (GameObject)Instantiate (UnitPrefabs [0], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\tbreak;\\n\\n\\t\\tcase 1:\\n        // Instantiates the first UnitPrefab (Element 1) from the array\\n\\t\\t\\tGameObject Chicken = (GameObject)Instantiate (UnitPrefabs [1], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\t\\tbreak;\\n\\n\\t\\tcase 2:\\n        // Instantiates the first UnitPrefab (Element 2) from the array\\n\\t\\t\\tGameObject ClockTree = (GameObject)Instantiate (UnitPrefabs [2], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\tbreak;\\n\\n\\t\\tcase 3:\\n\\t\\t\\tGameObject Mine = (GameObject)Instantiate (UnitPrefabs [3], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\t\\tbreak;\\n\\n\\t\\tcase 4:\\n\\t\\t\\tGameObject Gargoyle = (GameObject)Instantiate (UnitPrefabs [4], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\t\\tbreak;\\n\\n\\t\\tcase 5:\\n\\t\\t\\tGameObject Colossus = (GameObject)Instantiate (UnitPrefabs [5], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\t\\tbreak;\\n\\n\\t\\tcase 6:\\n\\t\\t\\tGameObject Monster = (GameObject)Instantiate (UnitPrefabs [6], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\t\\tbreak;\\n\\n\\t\\tcase 7:\\n\\t\\t\\tGameObject Porcupiner = (GameObject)Instantiate (UnitPrefabs [7], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\t\\tbreak;\\n\\n\\t\\tcase 8:\\n\\t\\t\\tGameObject Jelly = (GameObject)Instantiate (UnitPrefabs [8], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\t\\tbreak;\\n\\n\\t\\tcase 9:\\n\\t\\t\\tGameObject Wisp = (GameObject)Instantiate (UnitPrefabs [9], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\t\\tbreak;\\n\\n\\t\\tcase 10:\\n\\t\\t\\tGameObject Phoenix = (GameObject)Instantiate (UnitPrefabs [10], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\t\\tbreak;\\n\\n\\t\\tcase 11:\\n\\t\\t\\tGameObject Dragon = (GameObject)Instantiate (UnitPrefabs [11], spawnPoint, Quaternion.identity);\\t\\n\\t\\t\\tProcessUnit (\\\"Unit\\\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\\n\\t\\t\\tbreak;\\n\\t\\t}\\n\\t}\",\n      \"language\": \"csharp\",\n      \"name\": \"MenuArmyBattle.cs InstantiateUnit()\"\n    }\n  ]\n}\n[/block]\nThe respective unit is processed, but if you don't have your unit prefab in the UnitPrefabs[] array, by default the dobbit character is instantiated/processed. Just comment the unitType = “Dobbit”; statement and insert other prefabs into the cases above in InstantiateUnit() to process all your new characters.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Scripts/Menus/Army/MenuArmyBattle.cs\\n// Called by the InstantiateUnit() function\\n// with the unit object tag\\n// \\n\\n\\n\\tprivate void ProcessUnit(string unitType, float speedModifier)\\n\\t{\\n    // Game objects with the tag of soldier\\n    // Your kit may say something like dobbit. That doesn't matter\\n    // This is just a common tag that all unit game object prefabs should have\\n\\t\\tunitType = \\\"Soldier\\\";\\n\\n\\t// Locate the game objects\\n\\t\\tGameObject[] units = GameObject.FindGameObjectsWithTag(unitType);\\n    \\n    // For the number of units the player wants to deploy\\n\\t\\tfor (int i = 0; i < units.Length; i++) \\n\\t\\t{\\n\\t\\t\\tif(((Selector)units[i].GetComponent(\\\"Selector\\\")).isSelected)\\n\\t\\t\\t{\\n        // Assign the unit to a group, \\n        // setup a faster speed so they separate faster, \\n        // and instantiate the units on the map\\n\\t\\t\\t\\tunits[i].transform.parent = GroupUnits.transform;\\n\\t\\t\\t\\tunits[i].GetComponent<FighterController>().speed += speedModifier;\\n\\t\\t\\t\\tunits[i].GetComponent<FighterController>().assignedToGroup = ((Helios)helios).selectedGroupIndex;\\n\\n        // Instantiate a new unit with it's own unique unit index number\\n\\t\\t\\t\\ttempList.Add(units[i]);\\n\\t\\t\\t\\t((Helios)helios).DeployedUnits.Add(units[i]);\\n\\t\\t\\t\\t((Helios)helios).instantiationUnitIndex++;\\n\\t\\t\\t\\tunits[i].GetComponent<Selector>().index = ((Helios)helios).instantiationUnitIndex;\\n\\t\\t\\t\\t((Selector)units[i].GetComponent(\\\"Selector\\\")).isSelected = false;\\n\\t\\t\\t\\tbreak;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\",\n      \"language\": \"csharp\",\n      \"name\": \"MenuArmyBattle.cs ProcessUnit() function\"\n    }\n  ]\n}\n[/block]\nHere's an example with a cop soldier unit.\nChange the Sprite collections and add the animation clips. Since the Build animation was necessary only for the dobbit builder, it will not be processed during combat, you can add the idle cop animation. Drag this to the CopSoldier prefab to replace it (make sure you don't overwrite the dobbit soldier prefab). You might want to change the “bullet” in the Shooter script - the projectile that the unit is launching.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/0pjPAY00SmBKHmkYiLUg_cop.jpg\",\n        \"cop.jpg\",\n        \"1924\",\n        \"1032\",\n        \"#72ad35\",\n        \"\"\n      ],\n      \"caption\": \"Click on image to view larger\"\n    }\n  ]\n}\n[/block]\nOpen the Map01 scene, and in UIAnchor/UnitsBattle locate the unit either in Page0 or Page1 and replace the 01Graphics/SpPic sprite. In the below image excerpt you'll see where the alien sprite is located.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/0a8107f-sppic_2.jpg\",\n        \"sppic 2.jpg\",\n        665,\n        887,\n        \"#c5c5c5\"\n      ],\n      \"caption\": \"Click on image to view larger\"\n    }\n  ]\n}\n[/block]\nIn the Map01 scene, activate the UnitsBattle menu, and, in the Anchor - Bottom > UnitsBattle menu, drag your prefab, for example the new cop prefab into the existing unit slot you want to replace. Deactivate the menu, and launch the game.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/JasFZcs1SE2MyESfSi61_cop.jpg\",\n        \"cop.jpg\",\n        \"1924\",\n        \"1056\",\n        \"#77ae37\",\n        \"\"\n      ],\n      \"caption\": \"Click on image to view larger\"\n    }\n  ]\n}\n[/block]\nActivate the TransData game object in the Map01 hierarchy and press play to load a random map directly rather than going back to the Game scene to play the game. Make sure to deactivate the TransData game object when done.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/xP73be6zSNuOt6lcDp8i_cop.jpg\",\n        \"cop.jpg\",\n        \"1924\",\n        \"1056\",\n        \"#74a42f\",\n        \"\"\n      ],\n      \"caption\": \"Click on image to view larger\"\n    }\n  ]\n}\n[/block]\n*HINT: In case you do not see the unit, it may be related to scaling, try scaling it up by 100.* \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Next, continue to Part 2 to update the Unit menus in the Game scene\"\n}\n[/block]\nAfter you have setup the prefab in the battle map, we can return to the game scene to customize the menus. Continue to Part 2: Update Unit Menus in the documentation links on the left.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Want to know more about 2DTK? Watch these Tutorial Videos\"\n}\n[/block]\nTo learn more about sprites and animations with 2DTK, watch the videos below or see the [2DTK documentation](http://www.unikronsoftware.com/2dtoolkit/doc/) (for example [this one on creating sprite collection](http://www.unikronsoftware.com/2dtoolkit/doc/2.5/tutorial/creating_a_sprite_collection.html))\n[block:html]\n{\n  \"html\": \"<iframe width=\\\"560\\\" height=\\\"315\\\" src=\\\"https://www.youtube.com/embed/v9pBYc9KmC8?rel=0&amp;showinfo=0\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<iframe width=\\\"560\\\" height=\\\"315\\\" src=\\\"https://www.youtube.com/embed/xwLYy1yEerY?rel=0&amp;showinfo=0\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<iframe width=\\\"560\\\" height=\\\"315\\\" src=\\\"https://www.youtube.com/embed/CBZFRhKr7kg?rel=0&amp;showinfo=0\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\"\n}\n[/block]","excerpt":"","slug":"add-new-characters","type":"basic","title":"Part 1: Create Unit Prefabs"}

Part 1: Create Unit Prefabs


[block:callout] { "type": "success", "title": "Reminder - Keep Daily Backups", "body": "When working on a strategy game with a kit as big as the Complete Kit - always keep a working daily backup! Save yourself the trouble of rolling-back changes and losing work." } [/block] [block:api-header] { "type": "basic", "title": "What are unit prefabs?" } [/block] Every character in your game needs to be setup as a prefab. We've got 7 examples already setup in the game for you, they are as follows: [block:parameters] { "data": { "h-0": "Unit", "h-1": "Prefab", "0-0": "Alien", "1-0": "Handyman", "2-0": "Dobbit", "3-0": "Viking", "4-0": "Hydra", "5-0": "Mage", "6-0": "Archer", "0-1": "Alien.prefab", "1-1": "HandyMan.prefab", "6-1": "Archer.prefab", "2-1": "Dobbit.prefab (Hometown NPC)/DobbitSoldier.prefab (Army Battle)", "4-1": "Hydra.prefab", "5-1": "Mage.prefab", "3-1": "Viking.prefab" }, "cols": 2, "rows": 7 } [/block] [block:api-header] { "type": "basic", "title": "Create Your Own Unit Prefab Video Demo" } [/block] The following video demo explains how to create your unit prefabs. We use the Alien unit files which are available for download in the CityBuildingKit.com download center. [block:embed] { "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F4NuBGtYCaXw%3Ffeature%3Doembed&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D4NuBGtYCaXw%26feature%3Dyoutu.be&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F4NuBGtYCaXw%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\" width=\"854\" height=\"480\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "url": "https://www.youtube.com/watch?v=4NuBGtYCaXw&feature=youtu.be", "title": "Adding Unit - Tutorial #4", "favicon": "https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico", "image": "https://i.ytimg.com/vi/4NuBGtYCaXw/hqdefault.jpg" } [/block] [block:api-header] { "type": "basic", "title": "Getting Started..." } [/block] Before adding new characters, take a look at how our example character is structured. First, you will need sprite sheets for the new characters. These are either hand-drawn, or 3D renders from different angles with the character walking or performing different tasks. Our sprite sheets are in Sprites_TK2D (Assets\Sprites_TK2D\Units\Dobbit\walk). [block:image] { "images": [ { "image": [ "https://files.readme.io/iw5Pz6weQqS8ArYVQ6lK_spritesheet6.jpg", "spritesheet6.jpg", "800", "600", "#78555b", "" ], "caption": "Click on image to view larger. Assets\\Sprites_TK2D\\Units\\Dobbit\\walk sprite sheet" } ] } [/block] Here is a great tutorial from Digital Tutors for creating the sprite sheets: [block:html] { "html": "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/cRE2G96591E?rel=0&amp;showinfo=0\" frameborder=\"0\" allowfullscreen></iframe>" } [/block] We use a software called [Texture Packer](https://www.codeandweb.com/texturepacker) and we talk about how to get setup with it on the next doc. Then, you will need to create 2D Toolkit sprite collections and sprite animations. [block:code] { "codes": [ { "code": "Assets\\SpriteCollections_TK2D\\Units\\Animated\\Dobbit\\HIQ\n\tHIQ_dobbit_walk\n\tHIQ_dobbit_walk_animation", "language": "text" } ] } [/block] Copy the sprite sheet in Assets\Sprites_TK2D\Units\<Name of character> Folder Create a new folder in Assets\SpriteCollections_TK2D\Units\Animated\<Folder with same name>. Create new sprite collections and rename them <name>Idle, <name>Shoot, <name>Walk to keep things organized – due to the high number of frames (not recommended), we had to split the sprite collections. Open one, create 8 empty sprite sheets and drag the appropriate images, into the Texture slot. Press **Setup** for each as you drag each in. Fill in the individual sprite Width / Height, Pad Black Zero Alpha and press Apply. This will separate the sprite sheet into individual sprites for the atlas. Delete the last empty sprites(if any). [block:image] { "images": [ { "image": [ "https://files.readme.io/wWlBBG2vSCuCowzB4yXV_sprite-sheet1.jpg", "sprite-sheet1.jpg", "800", "600", "#607896", "" ], "caption": "Click on image to view larger. Individual animation frames with 2D Toolkit" } ] } [/block] We have split our collections based on actions (walk, idle, etc), but you can basically insert all sprite sheets/animations into one collection/animation, provided that the size of the resulting atlas image doesn't exceed the maximum allowed dimension. To make best use of the image atlas, you can dice each frame. Select all sprites, Render Mesh Diced, Apply to dice all sprites and hit **Commit** to create the Sprite Collection. [block:image] { "images": [ { "caption": "Click on image to view larger. Diced frame example", "image": [ "https://files.readme.io/pKLDB2m0TOm9uGtF607x_sprite-sheet2.jpg", "sprite-sheet2.jpg", "800", "600", "#805260", "" ] } ] } [/block] The frames are diced for better use of the sprite collection texture. [block:image] { "images": [ { "caption": "Click on image to view larger. Diced Atlas Image", "image": [ "https://files.readme.io/c70oao5Su6LwRPn8Dbo2_spritesheet3.jpg", "spritesheet3.jpg", "800", "600", "#648cbc", "" ] } ] } [/block] Then, take a look at our soldier prefab (Assets\Prefabs\Creators\Units\DobbitSoldier.prefab). Based on how our simple dobbit animation controller is configured, you will need 3 separate sprite animations, for Idle, Attack and Walk. The clips inside are called Idle_ or Attack_ or Walk_ + direction – N,S,E,W, NE,NW,SE,SW (North, South, etc) The basic components of an animated character are a 2D Toolkit Sprite and a Sprite Animator. Then, a series of controllers, the animation controller and other elements that make the character walk, change direction, attack, etc. [block:api-header] { "type": "basic", "title": "How to test animated units that I import?" } [/block] In the Scripts/Units/AnimController.cs Update() function there is a commented paragraph for manually testing animation/direction of units. Below is an excerpt. [block:code] { "codes": [ { "code": "// Scripts/Units/AnimController.cs\n// Function is commented out, but this will allow you to \n// Manually control units and test them with key presses\n// Movement keys: F R E W S X C\n// Animation Keys: I O K L\n//\nvoid Update () {\n\n\t//Manual controller to check animations\n\t/*\n\tbool animChanged = false;\n\tif(Input.anyKey){ animChanged = true; }\n\n\tif(Input.GetKey(KeyCode.F)){ direction = \"E\"; }\n\telse if(Input.GetKey(KeyCode.R)){ direction = \"NE\"; }\n\telse if(Input.GetKey(KeyCode.E)){ direction = \"N\"; }\n\telse if(Input.GetKey(KeyCode.W)){ direction = \"NW\"; }\n\telse if(Input.GetKey(KeyCode.S)){ direction = \"W\"; }\n\telse if(Input.GetKey(KeyCode.Z)){ direction = \"SW\"; }\n\telse if(Input.GetKey(KeyCode.X)){ direction = \"S\"; }\n\telse if(Input.GetKey(KeyCode.C)){ direction = \"SE\"; }\t\t\n\n\tif(Input.GetKey(KeyCode.I)){action = \"Idle\"; animator.Library = idleAnimation;\t\t}\n\telse if(Input.GetKey(KeyCode.O)){action = \"Walk\"; animator.Library = walkAnimation;\t\t}\n\telse if(Input.GetKey(KeyCode.K)){action = \"Attack\"; animator.Library = attackAnimation;\t\t}\n\telse if(Input.GetKey(KeyCode.L)){action = \"Build\"; animator.Library = buildAnimation;\t\t}\n\n\tif(animChanged){UpdateCharacterAnimation();}\n\t*/\n}", "language": "csharp", "name": "Scripts/Units/AnimController.cs Update() Function" } ] } [/block] [block:image] { "images": [ { "caption": "Click on image to view larger. Manually Testing Your Character", "image": [ "https://files.readme.io/VGoIeuYbQkieDL5s9FAp_spritesheet4.jpg", "spritesheet4.jpg", "800", "600", "#3e7ea8", "" ] } ] } [/block] At the time of this writing, there are seven animated characters in our kit as listed in the chart above. Study how these examples work. For NPC demonstrations, look at how the Construction Dobbit follows a fixed path around construction objects, while the soldier dobbit prefab is much more versatile for battle. [block:api-header] { "type": "basic", "title": "How do I setup my XML?" } [/block] Now, we need to update the units.xml file. This is pretty simple to do, since all you're editing here is the name and description plus prices and time. Settings that are imported by the game and aren't too critical. There's only one thing to remember - keep the same order in the XML as your prefab order in Unity. [block:callout] { "type": "warning", "body": "**Always keep the same order in all menus/XML files for all structures or units.**\n\nThe order in the XML file must match the order of units in the store. The first 5 units (starting with the Alien) appear on the top and the last 5 units (starting with the Mage) appear on the bottom of the menu. If you've changed the units in your UIAnchor ArmyMenu, this order must be the same in your XML or else things will get mixed up.\n\nAlso, later in documentation page Part 2: Update Units Menus the order of elements in the Inspector prefab array must match the same order you've used in the XML or else you'll find units get accidentally mixed up.", "title": "XML Order Must Match Prefab Order in Unity" } [/block] The following is a sample of the first XML item in the document, which matches the first prefab in Unity. [block:code] { "codes": [ { "code": "\t<Unit>\t\t\t\n\t\t<Name>Green Alien</Name>\n <!-- name displayed in the store -->\t\t\t\n \n\t\t<UnitType>Alien</UnitType>\n <!-- IMPORTANT: this same as prefab - instead of clutting the labels list you set the prefab name here in the XML. Prettier right? -->\t\n \n\t\t<Description>A smelly alien, green with envy. Maybe it's something he ate?</Description>\n <!-- description displayed in the store -->\t\n\n\t\t<Currency>Mana</Currency>\n <!-- either Gold, Mana, or Crystals to buy -->\t\t\n \n\t\t<Price>50</Price>\n <!-- amount of resource necessary to pay for the unit-->\n \n\t\t<TimeToBuild>1</TimeToBuild>\n <!-- the time (in minutes) needed to create the unit -->\n\n\t\t<Life>200</Life>\n <!-- HP of this unit -->\n \n\t\t<Size>1</Size>\n <!--how many population slots the unit occupies-->\n <!--by default it is 1, but you can increase this like 3, 5, 10, etc. -->\n\n\t\t<XpAward>100</XpAward>\n <!-- experience awarded for the completion of an object -->\n\t</Unit>", "language": "xml" } ] } [/block] [block:api-header] { "type": "basic", "title": "Where do I instantiate my units?" } [/block] Units are instantiated in Scripts/Menus/Army/MenuArmyBattle.cs in the InstantiateUnit() function. This has different cases for each of the units you've setup in your XML/units.xml file that prefills the store with your units. [block:callout] { "type": "warning", "body": "**Make sure the index here matches your XML/units.xml file part-for-part.**\n\nFor example, \"Unit\" or \"Dobbit\" or \"Soldier\" tag applies to all units, and is used for target identification. The kit uses the default \"Dobbit\" tag for all units but for ease of understanding, it should actually be changed to \"Unit\" as we've written in the below examples." } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/83ebd81-tag.jpg", "tag.jpg", 1366, 742, "#c4c4c3" ], "caption": "The kit uses the default \"Dobbit\" tag for all unit. Click to view larger." } ] } [/block] [block:code] { "codes": [ { "code": "// Scripts/Menus/Army/MenuArmyBattle.cs\n// The following function is triggered after a unit is deployed\n// in battle. The cases are included for the characters\n// \n// Depending on which unit is clicked in the menu\n// It will send the game object tag to ProcessUnit()\n// Which loads the correct game object. If no object exists\n// ProcessUnit() will default with the dobbit (builder/farmer) character\n// As of this time, the values carried\n//\n\tprivate void InstantiateUnit(int index, float speedModifier)\n\t{\n\t\tswitch (index) \n\t\t{\n\t\tcase 0:\n // Instantiates the first UnitPrefab (Element 0) from the array\n\t\t\tGameObject Wizard = (GameObject)Instantiate (UnitPrefabs [0], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\tbreak;\n\n\t\tcase 1:\n // Instantiates the first UnitPrefab (Element 1) from the array\n\t\t\tGameObject Chicken = (GameObject)Instantiate (UnitPrefabs [1], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\t\tbreak;\n\n\t\tcase 2:\n // Instantiates the first UnitPrefab (Element 2) from the array\n\t\t\tGameObject ClockTree = (GameObject)Instantiate (UnitPrefabs [2], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\tbreak;\n\n\t\tcase 3:\n\t\t\tGameObject Mine = (GameObject)Instantiate (UnitPrefabs [3], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\t\tbreak;\n\n\t\tcase 4:\n\t\t\tGameObject Gargoyle = (GameObject)Instantiate (UnitPrefabs [4], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\t\tbreak;\n\n\t\tcase 5:\n\t\t\tGameObject Colossus = (GameObject)Instantiate (UnitPrefabs [5], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\t\tbreak;\n\n\t\tcase 6:\n\t\t\tGameObject Monster = (GameObject)Instantiate (UnitPrefabs [6], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\t\tbreak;\n\n\t\tcase 7:\n\t\t\tGameObject Porcupiner = (GameObject)Instantiate (UnitPrefabs [7], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\t\tbreak;\n\n\t\tcase 8:\n\t\t\tGameObject Jelly = (GameObject)Instantiate (UnitPrefabs [8], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\t\tbreak;\n\n\t\tcase 9:\n\t\t\tGameObject Wisp = (GameObject)Instantiate (UnitPrefabs [9], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\t\tbreak;\n\n\t\tcase 10:\n\t\t\tGameObject Phoenix = (GameObject)Instantiate (UnitPrefabs [10], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\t\tbreak;\n\n\t\tcase 11:\n\t\t\tGameObject Dragon = (GameObject)Instantiate (UnitPrefabs [11], spawnPoint, Quaternion.identity);\t\n\t\t\tProcessUnit (\"Unit\", speedModifier); //As of now, what you type in the first function variable (Unit, or Wizard, etc.) doesn't matter\n\t\t\tbreak;\n\t\t}\n\t}", "language": "csharp", "name": "MenuArmyBattle.cs InstantiateUnit()" } ] } [/block] The respective unit is processed, but if you don't have your unit prefab in the UnitPrefabs[] array, by default the dobbit character is instantiated/processed. Just comment the unitType = “Dobbit”; statement and insert other prefabs into the cases above in InstantiateUnit() to process all your new characters. [block:code] { "codes": [ { "code": "// Scripts/Menus/Army/MenuArmyBattle.cs\n// Called by the InstantiateUnit() function\n// with the unit object tag\n// \n\n\n\tprivate void ProcessUnit(string unitType, float speedModifier)\n\t{\n // Game objects with the tag of soldier\n // Your kit may say something like dobbit. That doesn't matter\n // This is just a common tag that all unit game object prefabs should have\n\t\tunitType = \"Soldier\";\n\n\t// Locate the game objects\n\t\tGameObject[] units = GameObject.FindGameObjectsWithTag(unitType);\n \n // For the number of units the player wants to deploy\n\t\tfor (int i = 0; i < units.Length; i++) \n\t\t{\n\t\t\tif(((Selector)units[i].GetComponent(\"Selector\")).isSelected)\n\t\t\t{\n // Assign the unit to a group, \n // setup a faster speed so they separate faster, \n // and instantiate the units on the map\n\t\t\t\tunits[i].transform.parent = GroupUnits.transform;\n\t\t\t\tunits[i].GetComponent<FighterController>().speed += speedModifier;\n\t\t\t\tunits[i].GetComponent<FighterController>().assignedToGroup = ((Helios)helios).selectedGroupIndex;\n\n // Instantiate a new unit with it's own unique unit index number\n\t\t\t\ttempList.Add(units[i]);\n\t\t\t\t((Helios)helios).DeployedUnits.Add(units[i]);\n\t\t\t\t((Helios)helios).instantiationUnitIndex++;\n\t\t\t\tunits[i].GetComponent<Selector>().index = ((Helios)helios).instantiationUnitIndex;\n\t\t\t\t((Selector)units[i].GetComponent(\"Selector\")).isSelected = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}", "language": "csharp", "name": "MenuArmyBattle.cs ProcessUnit() function" } ] } [/block] Here's an example with a cop soldier unit. Change the Sprite collections and add the animation clips. Since the Build animation was necessary only for the dobbit builder, it will not be processed during combat, you can add the idle cop animation. Drag this to the CopSoldier prefab to replace it (make sure you don't overwrite the dobbit soldier prefab). You might want to change the “bullet” in the Shooter script - the projectile that the unit is launching. [block:image] { "images": [ { "image": [ "https://files.readme.io/0pjPAY00SmBKHmkYiLUg_cop.jpg", "cop.jpg", "1924", "1032", "#72ad35", "" ], "caption": "Click on image to view larger" } ] } [/block] Open the Map01 scene, and in UIAnchor/UnitsBattle locate the unit either in Page0 or Page1 and replace the 01Graphics/SpPic sprite. In the below image excerpt you'll see where the alien sprite is located. [block:image] { "images": [ { "image": [ "https://files.readme.io/0a8107f-sppic_2.jpg", "sppic 2.jpg", 665, 887, "#c5c5c5" ], "caption": "Click on image to view larger" } ] } [/block] In the Map01 scene, activate the UnitsBattle menu, and, in the Anchor - Bottom > UnitsBattle menu, drag your prefab, for example the new cop prefab into the existing unit slot you want to replace. Deactivate the menu, and launch the game. [block:image] { "images": [ { "image": [ "https://files.readme.io/JasFZcs1SE2MyESfSi61_cop.jpg", "cop.jpg", "1924", "1056", "#77ae37", "" ], "caption": "Click on image to view larger" } ] } [/block] Activate the TransData game object in the Map01 hierarchy and press play to load a random map directly rather than going back to the Game scene to play the game. Make sure to deactivate the TransData game object when done. [block:image] { "images": [ { "image": [ "https://files.readme.io/xP73be6zSNuOt6lcDp8i_cop.jpg", "cop.jpg", "1924", "1056", "#74a42f", "" ], "caption": "Click on image to view larger" } ] } [/block] *HINT: In case you do not see the unit, it may be related to scaling, try scaling it up by 100.* [block:api-header] { "type": "basic", "title": "Next, continue to Part 2 to update the Unit menus in the Game scene" } [/block] After you have setup the prefab in the battle map, we can return to the game scene to customize the menus. Continue to Part 2: Update Unit Menus in the documentation links on the left. [block:api-header] { "type": "basic", "title": "Want to know more about 2DTK? Watch these Tutorial Videos" } [/block] To learn more about sprites and animations with 2DTK, watch the videos below or see the [2DTK documentation](http://www.unikronsoftware.com/2dtoolkit/doc/) (for example [this one on creating sprite collection](http://www.unikronsoftware.com/2dtoolkit/doc/2.5/tutorial/creating_a_sprite_collection.html)) [block:html] { "html": "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/v9pBYc9KmC8?rel=0&amp;showinfo=0\" frameborder=\"0\" allowfullscreen></iframe>" } [/block] [block:html] { "html": "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/xwLYy1yEerY?rel=0&amp;showinfo=0\" frameborder=\"0\" allowfullscreen></iframe>" } [/block] [block:html] { "html": "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/CBZFRhKr7kg?rel=0&amp;showinfo=0\" frameborder=\"0\" allowfullscreen></iframe>" } [/block]