Flashlight on the Left Hand And a Pistol in the right hand

MissBig

Member
Hi, I have a flashlight in the left hand and a pistol in the right hand Which works great being able to have duel items. But I want to be able to toggle the pistol independently from the flashlight so I press t for toggle equip, and the pistol unequips, but the flashlight disappears as well, but in my inventory in runtime, the flashlight is still equipped though. Am I missing something?

Also, I am able to toggle flashlight unequipped and equipped with a different button, but since I am using F to turn on/off light, is there a way that when I turn off light, it becomes unequipped?

Edit: Just realized I didn't make the left arms for this situation. So now I can unequip/equip items independently.
Still need to know about my other question.

If I turn off the light, I want it to be unequipped as well, but it only works if I have a different toggle-equipped flashlight button

Edit again: I thought it was going to work, but it doesn't now.

Is anyone able to do a tutorial on how to get a flashlight in the left hand and a one-handed weapon in the right hand, and be able to toggle equipped independently?
 
Last edited:
Hi, I think the most logical way to approach what you want here is not to have the flashlight unequipped when the light is turned off, but rather the other way around, to have the light turned off when the item is unequipped and inversely when it is equipped - after all from what you're describing it sounds like we wouldn't be holding a deactivated flashlight.

So here's how it can be done by adding a few events to Character Item - add this below the existing properties :

C#:
        //Custom additions
        [SerializeField] protected UnityEvent m_EquipItemCompleteEvent;
        public UnityEvent EquipItemCompleteEvent { get { return m_EquipItemCompleteEvent; } set { m_EquipItemCompleteEvent = value; } }

        [SerializeField] protected UnityEvent m_StartUnequipItemEvent;
        public UnityEvent StartUnequipItemEvent { get { return m_StartUnequipItemEvent; } set { m_StartUnequipItemEvent = value; } }

Next add this line to CharacterItem.OnAnimatorItemEquipComplete() :

C#:
m_EquipItemCompleteEvent.Invoke();

And this one to CharacterItem.OnAnimatorItemUnequip() :

C#:
m_StartUnequipItemEvent.Invoke();

Next you'll need to add these two lines to the Events foldout in ItemInspector :

C#:
                    Shared.Editor.Inspectors.Utility.InspectorUtility.UnityEventPropertyField(PropertyFromName("m_EquipItemCompleteEvent"));
                    Shared.Editor.Inspectors.Utility.InspectorUtility.UnityEventPropertyField(PropertyFromName("m_StartUnequipItemEvent"));

And with this done, you can deactivate and activate the light object using these events (you can also disable the modules in Usable Action to avoid any interference) :

Capture d’écran (3539).png

You will however need to toy with the Wait For Animation Event options under the Equip and Unequip foldout to get the light to be displayed when the equipping is complete and the unequipping begins.

Now as I type all of this, I realize that I have to ask if you subscribe to the logic I'm showing here ? Do you have specific needs or logic behind the light activation or deactivation or are you ok with what I'm offering ? Lastly I'm aware that this only takes care of the activation and deactivation of the light object, not the sfx and animation, but I do think it can be a first step. If you do want to follow the equip and unequip events route, maybe creating modules activated on Equip/Unequip would be the best way.

Lastly since you mentioned tutorial, back in 2023 I started making a series of video tutorials, you can find the dedicated thread here as well as a tutorial on setting up a flashlight :


I haven't done a tutorial in a long while but am still open to requests, feel free to post there if you want. Sorry for the long text and I hope this was useful !
 
Hi, I think the most logical way to approach what you want here is not to have the flashlight unequipped when the light is turned off, but rather the other way around, to have the light turned off when the item is unequipped and inversely when it is equipped - after all from what you're describing it sounds like we wouldn't be holding a deactivated flashlight.

So here's how it can be done by adding a few events to Character Item - add this below the existing properties :

C#:
        //Custom additions
        [SerializeField] protected UnityEvent m_EquipItemCompleteEvent;
        public UnityEvent EquipItemCompleteEvent { get { return m_EquipItemCompleteEvent; } set { m_EquipItemCompleteEvent = value; } }

        [SerializeField] protected UnityEvent m_StartUnequipItemEvent;
        public UnityEvent StartUnequipItemEvent { get { return m_StartUnequipItemEvent; } set { m_StartUnequipItemEvent = value; } }

Next add this line to CharacterItem.OnAnimatorItemEquipComplete() :

C#:
m_EquipItemCompleteEvent.Invoke();

And this one to CharacterItem.OnAnimatorItemUnequip() :

C#:
m_StartUnequipItemEvent.Invoke();

Next you'll need to add these two lines to the Events foldout in ItemInspector :

C#:
                    Shared.Editor.Inspectors.Utility.InspectorUtility.UnityEventPropertyField(PropertyFromName("m_EquipItemCompleteEvent"));
                    Shared.Editor.Inspectors.Utility.InspectorUtility.UnityEventPropertyField(PropertyFromName("m_StartUnequipItemEvent"));

And with this done, you can deactivate and activate the light object using these events (you can also disable the modules in Usable Action to avoid any interference) :

View attachment 14203

You will however need to toy with the Wait For Animation Event options under the Equip and Unequip foldout to get the light to be displayed when the equipping is complete and the unequipping begins.

Now as I type all of this, I realize that I have to ask if you subscribe to the logic I'm showing here ? Do you have specific needs or logic behind the light activation or deactivation or are you ok with what I'm offering ? Lastly I'm aware that this only takes care of the activation and deactivation of the light object, not the sfx and animation, but I do think it can be a first step. If you do want to follow the equip and unequip events route, maybe creating modules activated on Equip/Unequip would be the best way.

Lastly since you mentioned tutorial, back in 2023 I started making a series of video tutorials, you can find the dedicated thread here as well as a tutorial on setting up a flashlight :


I haven't done a tutorial in a long while but am still open to requests, feel free to post there if you want. Sorry for the long text and I hope this was useful !

Thank you for taking the time to answer, but what I wanted won't work for this asset. When you make item set rules and you want a flashlight in the left hand and the pistol in the right hand, you still have to make a duel rule of pistol in the right hand and the flashlight in the left hand therefore, you can't have them working independently. If I want to use this asset, I might have to just try to use a pistol with a flashlight attached. I would have been doing this for the assaultRifle any way. So I might just go the easier route.
 
Hi, I thought you had the separate equipping/unequipping working, but in any case the Item Set Manager should allow for having only a flash light in your left hand or a pistol in your right hand or both at the same time, and switching between these three scenarios if you have a rule for each. I'm pretty sure that if you take example on the demo dual pistol wielding and take care of the animations setup, you should be able to achieve what you want. If you're still struggling with this I can offer one screenshare for free if you're interested.
 
Hi, I thought you had the separate equipping/unequipping working, but in any case the Item Set Manager should allow for having only a flash light in your left hand or a pistol in your right hand or both at the same time, and switching between these three scenarios if you have a rule for each. I'm pretty sure that if you take example on the demo dual pistol wielding and take care of the animations setup, you should be able to achieve what you want. If you're still struggling with this I can offer one screenshare for free if you're interested.
Yeah, I thought I had it, but I didn't. I'm going right through the demo to see how things work, which has taken longer than I though,t but I am starting to understand a lot more, also watching the tutorials over and over again. But thanks for your help.
 
Back
Top