Forum rules - please read before posting.

Controlling UFPS (equip/unequip/next item) through Action Lists

I got started with integrating AC and UFPS yesterday, and it SEEMS to be working okay so far.

One of the things I'd need in order to make this setup viable would be the ability to control some UFPS actions through AC action lists (as I'm not a coder and really only use AC for everything)

For instance, I want the player to unequip the currently held weapon (as otherwise, the arms continue to display over different cameras and cutscenes from the UFPS overlay camera) I figured the best way to do this would be to force unequip the gun so the player puts their arms down (and therefore have them not be visible over the cutscene)

Since I don't know how to control UFPS through scripts and code, the best way would be to forcibly simulate the 'T' key (equip/unequip) being pressed. Is there a way to do this in AC? Afaik, Active Inputs do the reverse, correct? (You press a key and they run an assigned Action List) Any action that tells Unity that 'T' is being pressed?

Is this the right way to go about this or is there another better approach?

Thanks

Comments

  • The integration provides a bridge between AC and UCC items in the form of the AC_UCC_Item script, but this works by having UCC be the effector and AC the reactor. That is, equipping an item in UCC will update AC, but not the other way around.

    To unequip an item in UCC, you will need to rely on custom code. Custom code can be triggered by AC either with a custom Action, or by invoking a script function directly with the Object: Call event or Object: Send message Actions.

    You should consult UCC's documentation / developer for details on how to manually update the UCC selected item. With the code, I can advise on how to call it from within AC using the above.

    See also this thread on the UCC forums related to unequipping items via AC.

  • edited October 16

    Ok so does this basically mean that using UCC = making UCC the main base for game development, and AC acts as a secondary system? I'm very AC and Action List reliant, so that sounds like a tough transition (if I'm reading the situation correctly?)

    If this is the case, I'll adjust the game's design and only use a UCC character in those very specific scenes where I aim to have combat and will use an AC character for the rest of the majority of the game/ scenes. So am I correct about UCC becoming the main/ primary engine when using a UCC character?

  • When it comes to the character's control, yes. AC will take over the character during e.g. cutscenes so that they respond to Action commands, but control over the character during gameplay is handled by UCC.

  • Alright, thanks. I'll try out a few things and take a call!

  • edited October 16

    One of the issues I'm having is with the hotspot detector. It was initially set to the players head/ camera. As UFPS has its camera set outside the player, if I want the hotspot detector to follow the cameras rotation, I have to make it a child of the UCC camera. But this means the detector is then not a child of the Player, which AC doesn't allow. Any solution to this?

    Still seems to work even when not parented to the player

  • edited October 17

    I'm still trying to simulate a button press through AC though. I used the code from this thread to simulate an AC menu button press - https://www.adventurecreator.org/forum/discussion/9069/pressing-menu-buttons-through-actionlist-scripting-commands

    The button itself has Click Type set to Simulate Input, with the Input Axis set to the Input that I want it to simulate as seen in the screenshots:

    imageScreenshot-13" alt="" title="" />

    imageScreenshot-12" alt="" title="" />

    imageScreenshot-10" alt="" title="" />

    imageScreenshot-8" alt="" title="" />

    imageScreenshot-11" alt="" title="" />

    But when I run the Action List, nothing happens. Is my setup incorrect, or have I misunderstood what Click Type -> Simulate Input means?

  • The Action looks OK, in that it should cause the Menu Button to behave as though it were clicked.

    You can check that this is the case by temporarily switching its Click type to e.g. Turn Off Menu to see if running the Cutscene causes the Menu to close.

    The Simulate Input click type causes AC to act as though the supplied input was pressed. This only works for AC inputs, mind: things like InteractionA, ToggleCursor etc. It's not something you can use to simulate inputs used by other assets.

    If you're looking to control your UCC character, you'll need to affect it directly with custom code as in my first reply.

  • So I've tried to add custom code to equip/ unequip as suggested by lifting the script off their documentation from the API section here.

    I'm trying to turn it into a Custom Action. Is this the correct implementation? I don't really know programming so not sure if this approach is way off:

    using UnityEngine;
    using Opsive.UltimateCharacterController.Character;
    using Opsive.UltimateCharacterController.Character.Abilities.Items;
    
    
    namespace AC
    {
        [System.Serializable]
    
        public class ActionToggleEquip : Action
        {
            [Tooltip("A reference to the Ultimate Character Controller character.")]
            [SerializeField] protected GameObject m_Character;
    
            /// <summary>
            /// Equips the item.
            /// </summary>
            private void Start()
            {
                var characterLocomotion = m_Character.GetComponent<UltimateCharacterLocomotion>();
                if (characterLocomotion != null)
                {
                    // Equip a specific index within the ItemSetManager with the EquipUnequip ability.
                    var equipUnequip = characterLocomotion.GetAbility<EquipUnequip>();
                    if (equipUnequip != null)
                    {
                        // Equip the ItemSet at index 2 within the ItemSetManager.
                        equipUnequip.StartEquipUnequip(1);
                    }
                }
            }
        }
    
    
    }
    
  • I'm afraid not - Actions aren't MonoBehaviour scripts, you can't rely on standard Mono functions such as Start.

    Rather than converting it to an Action, though, it's easier to just use the Object: Call event or Object: Send message Action to run code that is in a MonoBehaviour script.

    Change the script back to a regular MonBehaviour script (replace Action with MonoBehaviour) and then attach it to your character.

    Rename "private void Start" with "public void ToggleEquip", and you can then access it with the above Actions.

  • That works! I can successfully unequip using that Action and script. I'm still trying to figure out how to re-equip through code, will get back on that with my progress. Thanks as always!

  • edited October 19

    Done! Here's the solution for anyone else that needs it. It's not the cleanest as it requires a separate script for each item, but it works.

    Unequip script:

    using UnityEngine;
    using Opsive.UltimateCharacterController.Character;
    using Opsive.UltimateCharacterController.Character.Abilities.Items;
    
    public class ActionUnEquip : MonoBehaviour
    {
        [Tooltip("A reference to the Ultimate Character Controller character.")]
        [SerializeField] protected GameObject m_Character;
    
        /// <summary>
        /// Equips the item.
        /// </summary>
        public void ToggleEquip()
        {
            var characterLocomotion = m_Character.GetComponent<UltimateCharacterLocomotion>();
            if (characterLocomotion != null)
            {
                // Equip a specific index within the ItemSetManager with the EquipUnequip ability.
                var equipUnequip = characterLocomotion.GetAbility<EquipUnequip>();
                if (equipUnequip != null)
                {
                    // Equip the ItemSet at index -1 within the ItemSetManager.
                    equipUnequip.StartEquipUnequip(-1);
                }
    
    
            }
        }
    }
    

    Just replace the -1 in the last line to the corresponding item set number. So if Pistol is item set 0, write in 0 to equip the pistol etc. -1 is to unequip whatever is currently equipped. Attach it to the character and do Object>Call Event>Action Unequip>Toggle Equip () Thanks again Chris!

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.