UMA Integration

You are here:
← All Topics
Version:2019.202Requirements:uMMORPG3d, Tools, Character CreationScript Define:None
Core Changes:YesTutorial Video:No

Description

This AddOn Integrates Unity Multipurpose Avatar with uMMORPG.


Core Changes

  1. [Required] Open the following script NetworkManagerMMO.cs. See Changes...
    Locate and Remove/Comment Out:
        private void LoadPreview(GameObject prefab, Transform location, int selectionIndex, CharactersAvailableMsg.CharacterPreview character)
        {
            // instantiate the prefab
            GameObject preview = Instantiate(prefab.gameObject, location.position, location.rotation);
            preview.transform.parent = location;
            Player player = preview.GetComponent();
    
            // assign basic preview values like name and equipment
            player.name = character.name;
            for (int i = 0; i < character.equipment.Length; ++i)
            {
                ItemSlot slot = character.equipment[i];
                player.equipment.Add(slot);
                if (slot.amount > 0)
                {
                    // OnEquipmentChanged won't be called unless spawned, we
                    // need to refresh manually
                    player.RefreshLocation(i);
                }
            }
    
            // add selection script
            preview.AddComponent();
            preview.GetComponent().index = selectionIndex;
        }
  2. [Required] Open the following script NetworkManagerMMO.cs. See Changes...
    Locate and Remove/Comment Out:
        private Player CreateCharacter(GameObject classPrefab, string characterName, string account)
        {
            // create new character based on the prefab.
            // -> we also assign default items and equipment for new characters
            // -> skills are handled in Database.CharacterLoad every time. if we
            //    add new ones to a prefab, all existing players should get them
            // (instantiate temporary player)
            //print("creating character: " + message.name + " " + message.classIndex);
            Player player = Instantiate(classPrefab).GetComponent();
            player.name = characterName;
            player.account = account;
            player.className = classPrefab.name;
            player.transform.position = GetStartPositionFor(player.className).position;
            for (int i = 0; i < player.inventorySize; ++i)
            {
                // add empty slot or default item if any
                player.inventory.Add(i < player.defaultItems.Length ? new ItemSlot(new Item(player.defaultItems[i].item), player.defaultItems[i].amount) : new ItemSlot());
            }
            for (int i = 0; i < player.equipmentInfo.Length; ++i)
            {
                // add empty slot or default item if any
                EquipmentInfo info = player.equipmentInfo[i];
                player.equipment.Add(info.defaultItem.item != null ? new ItemSlot(new Item(info.defaultItem.item), info.defaultItem.amount) : new ItemSlot());
            }
            player.health = player.healthMax; // after equipment in case of boni
            player.mana = player.manaMax; // after equipment in case of boni
    
            return player;
        }
    
  3. [Required] Open the following script NetworkManagerMMO.cs. See Changes...
    Locate this line:
        Player player = CreateCharacter(playerClasses[message.classIndex].gameObject, message.name, account);

    Modify to match:

        Player player = CreateCharacter(playerClasses[message.classIndex].gameObject, message.name, account, message.dna);
  4. [Required] Open the following script Player.cs. See Changes...
    Locate this line:
        private void OnEquipmentChanged(SyncListItemSlot.Operation op, int index, ItemSlot slot)
        {
            // update the model
            RefreshLocation(index);
    
            Utils.InvokeMany(typeof(Player), this, "OnEquipmentChanged_");
        }

    Add this line:

        private void OnEquipmentChanged(SyncListItemSlot.Operation op, int index, ItemSlot slot)
        {
            // update the model
            UpdateUma();
            RefreshLocation(index);
    
            Utils.InvokeMany(typeof(Player), this, "OnEquipmentChanged_");
        }
  5. [Required] Open the following script Player.cs. See Changes...
    Locate this line:
    if (info.location.childCount > 0) Destroy(info.location.GetChild(0).gameObject);

    Modify to match:

      if (info.location.childCount > 0)
      for(int i = 0; i < info.location.childCount; i++)
          ProcessBones(info.location);

Installation

  1. [Required] Install UMA 2.0 from the Asset Store.
  2. [Required]* Add the following _UMA to Scripting Define Symbols.
    Note: Found under Edit > Project Settings > Player > Configuration, append to the end.
  3. [Required] Apply all core changes.
  4. [Required] Goto Assets > UMA > Getting Started > UMA_DCS and drag this into your scene. This is required to calculate all UMAs in your scene.
  5. [Required]* Assign all UMATextRecipes for Hair Styles and Clothing on UCE_UI_CharacterCreation.
    Note: The defaults can be found at UMA > Content > UMA_Examples > HumanFemale/HumanMale > Recipes. (Make sure the index matches under the shirt and pants buttons, for correct functionality.)
  6. [Required]* Replace original Player prefabs with new Uma Prefab in /Prefabs. Follow the same steps you would normally take when creating different classes. *Note: Don’t forget to add your new Player Prefabs to the NetworkManager.
  7. [Optional] UMA_NPC available in Prefabs.
  8. [Optional] UMA_MONSTER available in Prefabs.
  9. [Optional] Take a look at the Folder Scripts > UI for UI editing use cases. More details below.
  10. [Required]* Make sure all Equipment, minus objects in hands, have a UMA Recipe for both male and female.
    Note: Equipment Category must match the equipment info slot or errors occur.

Extra

  • To use GameObjects in Equipment slots, Create an empty GameObject on any bone as the EquipmentInfo Location.
  • In the UCE_UI_CharacterCreation, all Male and Female Hairstyles, and ‘Underwear’ are handled.

  • To use UMATextRecipes as ‘Underwear’ Properly, you must goto the Recipe and make sure it is set to slot ‘Underwear’ and the Shared color[0] is set to ‘Undies’.

  • UCE_UmaGenderButton.cs: Create a UI > Button, Attach Script, Select Male or Female

  • UCE_UmaHairStyleButton.cs: Create a UI > Button, Attach Script, Select both Male and Female Index the button should select from UCE_UI_CharacterCreation.

    • [Optional] Index text update parameter.

  • UCE_UmaHairStylesButton.cs: Create a UI > Button, Attach Script, Toggle Increase to act as an Increase button, or Deselect to act as a Decrease Button. This reads your gender and increases or decreases the index of said hairstyles.

  • UCE_UmaSelectClothingButton.cs : Create a UI > Button, Attach Script, Select both Male and Female Index the button should select from UCE_UI_CharacterCreation.

    • [Optional] Index text update parameter.

  • UCE_UmaChangeClothingButton.cs : Create a UI > Button, Attach Script, Toggle Increase to act as an Increase button, or Deselect to act as a Decrease Button. This reads your gender and increases or decreases the index of said ‘Underwear’ Clothing.

  • UCE_UmaEditColors.cs : Create a UI > Image, Attach Script, Select Category from Dropdown. [Required] Select Sprite Asset and be sure to toggle ON Read/Write Enabled.

    This will allow you to select the color of the pixel you click and set the field from the dropdown.

Support the IndieMMO Team Today!

Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.