Forum rules - please read before posting.

Combat Example help

I'm using the Combat Example downloadable asset to try to make some combat with that for my game. I'd rather not use the custom inventory that comes with that, what would be the easy way to equip and unequip different weapons for the player using the combat scripts?

I also think the combat script could be expanded; Would be great if I could add more than just one type of animation and sound for each weapon. For example, I want to have some attack combos, with several different sounds that would be chosen at random.

Comments

  • edited November 2023

    To give something of a caveat: it's not an "official combat extension" for AC, but rather a practical example on how gameplay can be extended through custom script.

    The equipping of items is handled by the PlayerCombat script's EquipWeapon function. To have this run when clicking items in e.g. the default Inventory menu, hook into the OnMenuElementClick custom event and extract the clicked item instance:

    using UnityEngine;
    using AC;
    using AC.CombatExample;
    
    public class CustomEquipWeapon : MonoBehaviour
    {
    
        public int weaponCategoryID = 1;
    
        void OnEnable () { EventManager.OnMenuElementClick += OnMenuElementClick; }
        void OnDisable () { EventManager.OnMenuElementClick -= OnMenuElementClick; }
    
        void OnMenuElementClick (Menu menu, MenuElement element, int slot, int buttonPressed)
        {
            if (element is MenuInventoryBox)
            {
                MenuInventoryBox inventoryBox = (MenuInventoryBox) element;
                InvInstance clickedInstance = inventoryBox.GetInstance (slot);
                if (InvInstance.IsValid (clickedInstance) && clickedInstance.InvItem.binID == weaponCategoryID)
                {
                    PlayerCombat.Instance.EquipWeapon (clickedInstance);
                }
            }
        }
    
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.