Blocking equip

Silver100

Member
I have a player flying a ship where the equip ability needs disabling whilst in the ship. I managed to change volume to 0 just to prevent weapon sound. I did try start/stop ability. I was thinking maybe duplicate the player camera and another duplicate player (with no weapons attached) but felt this may be a bit extreme. Is there a way to arrange an on trigger disable equip button, other than event system which I struggle with?
 
Last edited:
Thanks, looks like figuring out the state system is the way forward and will eventually save me time. I can see an existing pre-set DisableEquipNextPreset which is just what I need but for some reason I cant use this, I'm guessing some existing presets are for the demo character only?
Other pre-sets seem to work instantly when you change them manually like the "ZoomThirdPersonAdventurePreset" where you can alter the zoom on off set by changing value on the value on the Z Axis which is very useful and simple too.

I did try creating a new state too clicked persist but wont register like the existing presets.

I maybe wrong here but from my understanding you drag the state pre-set i.e. "DisableEquipNextPreset" into public field once set up to have access enabling/disabling?
I tried placing this in my script as explained here but not yet able to get working.
https://opsive.com/support/documentation/ultimate-character-controller/state-system/;

Code:
 StateManager.SetState(m_Character, "DisableEquipNextPreset", true);
I have managed an alternative process for now, by disabling the players weapon sounds and players visual components whilst flying the ship so the player is not noticed through the ship when equipping is pressed, when flying the ship now.
 
Last edited:
You do not need to do any programming for this scenario. You can use the StateTrigger component to enable a state when within a trigger (such as adding it to your ship). This is similar to how the demo scene works. For example, when you are in the shooter zone you are not able to equip melee items using the state system.
 
Thanks, that has been an ongoing issue for me would be great to finally figure it out.

The state system looks very good and useful, the issue I am having is new states created are never being registered in Unity.
I can use default pre-sets but not create new ones.

I would still need the "DisableEquipNextPresetstate" attached to the player under item ability in the inspector, but existing pre-sets wont attach
I cant create new ones using the plus they don't register?

Checked my projects directory looks correct state is saving in my project

I created a new pre-set by clicking the plus sign under item ability on equip next item.

(named "DisableEquipNextitemtest") so I can locate and delete safely)

In the hierarchy my newly created State will now appear in the correct location on the actual item ability in the inspector

**Pressed persist / then activate after to test working

Add property enabled

Tested by unchecking bool box enabled and no response the player is still able to equip

Looked at other pre-sets and how they work to see what I am missing and re-checked the state system tutorials too matching those steps.

**Pressing persist & activate in the tutorial State system (6.40 mins in) the values get recorded after persist but not the case when I try those steps it wont work i.e persist then activate for the new values isn't working.

Zoom state seems fine manually adjusting preset state I have access to this when checking the pre-set for zoom state? I can only work with the default states on set up.
 
Last edited:
For this you can place the StateTrigger component on your ship, and name it a state called "Ship". On your EquipUnequip ability you would then create a new preset and within that preset you deselect Enabled. On the EquipUnequip ability you can name this state "Ship" and the ability will deactivate when the character is within the trigger. I recommend taking a look at the demo scene's StateTrigger as it is setup in a similar way.
 
Thanks for your help trying to resolve this, but I followed exactly above with the state trigger component and followed the tutorials a few times over too,) still not working for me at least. I looked at the demo comparing the way gravity zone pre-set is handled and set up too. Tested manually checked the enable box on newly created pre-sets not responding though.
 
Last edited:
Thanks no problem, I have added the link below. I have tried with a simple cube too as the ships parented to the player so would be on the same layer so hopefully will still work. Basically I'm alternating the enable pre-set tick box button seeing if there are changes.

I have created in a new project I have started on, seems to be working well just need to test in my main game;


What I am trying to achieve is to make sure the player cant equip/unequip when in the ship so no Items will protrude through
the ship (the cube for now in the test) other during accidental equip press.

From my understanding the state system records values that you can then recall.

In my case I want the a value of equip/unequip to unchecked status just as you mentioned.

So I have created a state named 'test' attached to the players item ability. Unchecked enable in inspector, on the newly created equip/unequip (appearing in the asset folder)

When the player enters the cubes collider with the 'state trigger script' with state name field also set as 'test' attached the player is now no longer able to equip/unequip which is perfect, Understanding the state system will save me having to code lots of set active code disabling components etc.

The ship parented to the player seemed an issue, however creating separate zone / collider to deactivate works fine. I can then even alter the state tab to have say, 'run' to block equip instead etc.
Really appreciate your help on this finally there :)
 
Last edited:
You named the state within the StateTrigger "Ship" but on the EquipUnequip ability you named it "test". These two names must match in order for it to know what preset is affected.
 
Thanks, In this test video and test project shown I have named 'test' on both trigger and equip/unequip ability I will check my video clip again. In my actual project I named them both as 'ship', indeed as long as they both match. Appreciated It works perfectly. :)
 
Last edited:
Top