Specific weapon setup direction

AntL

Member
Hey Justin, was just after some general direction on how I could accomplish the following. Basically I'd like to have a projectile weapon that the player is always able to fire regardless of the 'primary' weapon that is currently equipped (it'll be situated on the rear of the player's glove - see Iron Man image!) . So for example the player could be holding/firing an assault rifle or pistol etc and by pressing a secondary fire, would immediately trigger this weapon regardless of what else is equipped.

Could you please give me a rough direction on how to approach this?

Thanks so much!


Main-29.jpg
Iron Man reference
 

Justin

Administrator
Staff member
You would take an approach similar to the secondary grenade. The ItemSet page describes how this was setup:


Basically the weapon is always equipped with a separate Item Set category so it can then be used at any time.
 

AntL

Member
Hey @Justin, so I'm still trying to create a weapon that is constantly available for the player to fire in their left hand. As you say it should copy the functionality of hte secondary grenade - player presses button and the weapon will activate, the existing weapon will momentarily be removed and the new weapon will fire on release then restore the previous weapon.

I've added an Equip/Unequip and Toggle equip item ability for a category I've called LeftHandPersistent which is what my new weapon is assigned to (I'm currently using the pistol model). The Use Item Ability is activated on Button down, and stopped on button up with the correct input name.

It nearly works - the gun behavaes as expected and fires properly via the correct button etc, but if I set up my LeftHandPersistent category as per the screenshots ( itemset0, itemset1) then the new weapon is constantly present (I'm currently using Pistol model) and at the same time as the weapons in the right hand.

The only way to get around this is to untick the 'enabled' on the item set that has the new weapon, but then the CanStartAbility() returns false. So which part of the puzzle am I missing to make the new weapon appear fire and then disappear (i.e. not be onscreen continually)?

Thanks again!
 

Attachments

Last edited:

Justin

Administrator
Staff member
On the first mesh arms mesh the ObjectActivator component will activate/deactivate the mesh depending on the ItemSet that is equipped. This component is not added automatically so you'll want to add it. This will prevent the mesh from being visible when it shouldn't be.
 

AntL

Member
Ok, so if I understand correctly, I'd add a state to the Item Set that contains the weapon. As the object is on NolanFirstPersonLeftArms, I'd want to add the object activator with the new state specified and the 'DeactivateObjectActivatorPreset' to any limbs that I want disabled when the weapon is active? That seems to make sense, but it doesn't solve my issue as I don't think the state is being set - in statebehaviour I've added a debug log and nothing is being outputted:


Code:
        /// <summary>
        /// Activates or deactivates the specified state.
        /// </summary>
        /// <param name="stateName">The name of the state to change the activate status of.</param>
        /// <param name="active">Should the state be activated?</param>
        public void SetState(string stateName, bool active)
        {
            Debug.Log("StateName: " + stateName);
            StateManager.SetState(this, m_States, stateName, active);
        }
 

Attachments

Justin

Administrator
Staff member
Does your ItemSetManager contain the GravityGun state? This is where that state would be set.
 

AntL

Member
Indeed it does.

A couple of questions on this as I've tried copying the seconadary grenade setup for this, but it I just seem to end up with the hand on screen all the time.

1. What do the different auto equip options do on Equip/Unequip? Which should I use, if I want to 'activate' the object with a button?

2. How should the equip/unequip start and stop types be set up? Should they be set to button down, and have that button as they same input on the Use ability that actually fires them? (so effectively pressing the button both equips and fires the weapon with the same keypress)?

Running at a bit of a loss as to why this isn't working!


Thanks!
 

Attachments

Last edited:

Justin

Administrator
Staff member
Does that Item Set get activated? It'll call SetState on line ItemSetManager.UpdateActiveItemSet.

1. I just added what the auto equip options are to this page. If you manually want to equip the item then you should not have any of the auto equip options.

2. If you want the character to equip with a button press then the start type should be button down. You're wanting the item to be equipped all of the time though, right? In this case I would have it automatically equip within its own item category. It sounds like this is what you are doing though.
 

AntL

Member
If the auto equip option is set to always, then the weapon is assigned to slot 1 and works, but it's visible and active all the time. I only want it visible when a button is pressed, the the weapon to fire then move off screen when the button is released. So does this mean I always want the weapon equipped (but not visible)?

Do you do paid support ;-)
 

Justin

Administrator
Staff member
If the auto equip option is set to always, then the weapon is assigned to slot 1 and works, but it's visible and active all the time. I only want it visible when a button is pressed, the the weapon to fire then move off screen when the button is released. So does this mean I always want the weapon equipped (but not visible)?
Interesting item :) I would treat this similar to the secondary grenade as you have been where the item is invisible, but then when it fires it spawns the visuals. This will prevent the odd case where you want to have the item both equp and used with the same button press.

Do you do paid support ;-)
I do :) Right now I have a huge backlog though so I won't be able to take anything new on until after version 2.2 is released.
 
Top