Topic: Enable/Disable weapons in Combat Stances

Hello @FreedTerror. I have a request for you. Could you please re-upload the new script for Enable/Disable weapons in Combat Stances? I accidentally deleted it from my project. Thank you very much. I would be very grateful to you.

Share

Thumbs up Thumbs down

Re: Enable/Disable weapons in Combat Stances

Sure thing. I'll edit my post when I can.

Share

Thumbs up Thumbs down

Re: Enable/Disable weapons in Combat Stances

Thank you

Share

Thumbs up Thumbs down

Re: Enable/Disable weapons in Combat Stances

using System.Collections.Generic;
using UFE3D;
using UnityEngine;

public class NewBehaviourScript1 : MonoBehaviour
{
    private ControlsScript controlsScript;

    [System.Serializable]
    public class Options
    {
        public CombatStances[] combatStances;
        public GameObject[] disableGameObjects;
        public GameObject[] enableGameObjects;
    }
    public Options[] options;

    private void Start()
    {
        controlsScript = GetComponentInParent<ControlsScript>();
    }

    private void Update()
    {
        if (controlsScript != null)
        {
            for (int i = 0; i < options.Length; i++)
            {
                for (int j = 0; j < options[i].combatStances.Length; j++)
                {
                    if (controlsScript.MoveSet.currentCombatStance == options[i].combatStances[j])
                    {
                        SetGameObjectActive(options[i].disableGameObjects, false);
                        SetGameObjectActive(options[i].enableGameObjects, true);
                    }
                }
            }
        }
    }

    #region GameObject Methods

    public static void SetGameObjectActive(GameObject[] gameObject, bool active)
    {
        if (gameObject == null)
        {
            return;
        }

        int length = gameObject.Length;
        for (int i = 0; i < length; i++)
        {
            var item = gameObject[i];

            if (item == null)
            {
                continue;
            }

            item.SetActive(active);
        }
    }

    public static void SetGameObjectActive(List<GameObject> gameObject, bool active)
    {
        if (gameObject == null)
        {
            return;
        }

        int count = gameObject.Count;
        for (int i = 0; i < count; i++)
        {
            var item = gameObject[i];

            if (item == null)
            {
                continue;
            }

            item.SetActive(active);
        }
    }

    #endregion
}

Share

Thumbs up +1 Thumbs down

Re: Enable/Disable weapons in Combat Stances

Thank you very much

Share

Thumbs up Thumbs down

Re: Enable/Disable weapons in Combat Stances

Hi @FreedTerror. I want to ask you if this script could be extended by Body Parts Visibility Changes. In Enabled objects for specific Stance for a specific Move add an exception. So that the object is invisible for certain Move in Enabled game objects for selected Stance. thank you

Share

Thumbs up Thumbs down

Re: Enable/Disable weapons in Combat Stances

You want to enable and disable objects based on what stance and what move the character is doing?
I can add that sometime.

Share

Thumbs up +1 Thumbs down

Re: Enable/Disable weapons in Combat Stances

Exactly. That would be great.

Share

Thumbs up Thumbs down