Equip / Unequip freeze occasionally after rifle use

Silver100

Member
Hi,

Just noticed an intermittent issue in my project where occasionally it's possible for the Equip/ Unequip to stop its ability all together. I'm not sure what causes it hard to tell but will experiment more. Is there any way this can be prevented or code method to detect player equip is in a state of lock and equip ability to return to normal function?
 
Last edited:
This is likely an animation event issue. Ensure that the all of the events on the ability are either being fired through the animation event or your are using a timer for equipping and unequipping.
 
Thanks, I'm not sure how to check for events being 'fired through the animation event'. I would assume they are as I have made no changes directly to the ability. When you refer to timer for equip/unequip do you mean just a value in wait for animation event on the animator component?
I'm using the demo controller for my character (none of my own animations active). The equip ability its currently set at default settings which always worked, never changed this. The only changes made for animation events so far were on the sword and rifle animation component. Most settings are set to 0 to work on sword. Rifle is set 0.3 for wait for animation and equip complete event '0' default . The use rate set to 0 for a more immediate response on sword, and most of wait for animation event set to 0 (or the animation never played at all on set up had no response) should I ensure that all animation events be at 0? Checking an the forum tutorials changing the settings for wait for events to 0 helped and usually runs well that way . My equip set up is; Scroll through rifle sword then unequip - This order is important as I have implemented triggers to enable sound and fire ability so has to follow that order. Using Equip next item ability and unequip (no toggle being used) Interesting adding an API Equip/Unequip with sword set in anim to a pick up immediately unblocks the locked in rifle state. Is there a way to determine what value to put In wait for animation event or is it trial and error?

Note; Also just check removing the wait for animation on rifle literally set all to 0 so animation never plays on equip/unequip and still able to produce issue. However assigned a button with the Opsive API Equip/Unequip script attached (forcing sword to equip) seems to wok. I think its something to do with the scroll through weapons equip next item ability (The sword suddenly becoming unavailable so stuck on just rifle)
 
Last edited:
I have finally managed to identify the error and the exact cause after testing.

If fire is held whilst rifle equipped while attempting to change to sword at same time then equip/unequip/next ability becomes blocked

Also I'm using the API Equip/Unequip on my pickups works well (API's are brilliant for helping with code);

Same issue here;

equipUnequip.StartEquipUnequip(2); (sword) there's conflict with fire button at the exact moment anim starts will freeze equip

Holding down the fire button at the same time as a triggered animation using the forced anim equip/unequip API Unequip(2) sword is the exact cause.

equipUnequip.StartEquipUnequip(1); = Rifle works fine on start up being combined with fire
equipUnequip.StartEquipUnequip(2); = Sword becomes blocked if initiated with combined with rifle fire and stays locked in rifle state.
 
Last edited:
One helpful way to debug this is to enable logging on the animator controller for the item parameters so you can see what is being fed into the animator. With that said, I just tried to reproduce something similar in the demo scene but wasn't able to. Are you able to? That would help me tell what is going on.

A way to fix that specific scenario is to call UltimateCharacterLocomotion.IsAbilityTypeActive<Use>() and if it is then either stop the ability, or you could prevent EquipUnequip from starting if that is what you would rather do.
 
Thanks, yes the demo scene seems fine It requires F key to be pressed, but no auto pick up to compare to (unless it can be activated). My project uses auto pick up. I implemented API equip to my code Rifle/Machine gun buttons as my own code for pick up and shooter code initially had an issue. My code (using different method here), switches sound and gunspawn component for: rifle/sword unequipped - this is attached directly to the camera to spawn bullets from centre of the screen. This makes it tricky to disable/enable tagged components with colliders (not directly attached to player so my collider based system (on trigger other type code) for detect equip status was not possible - The player would fire unequipped. Adding these API's rescued the situation as its now not possible to be unequipped upon pick up or switching shooter / sword, so works much better. It works very well but the scroller could lock if button with (API equip rifle (1) method) and fire button held at the exact same time. To avoid this more I have assigned addition direct sword equip API (2) button this will unlock the state if locked. I have a UI text stating the direct rifle or sword buttons to press, so the equip next item scroller is not the main choice so less likely to enter issues. This idea you mentioned 'UltimateCharacterLocomotion.IsAbilityTypeActive<Use>() sounds a good' I may be getting confused here but would I just need to Implement this to the API Unequip/Equip Code or would I need to create a new block type of ability? or both methods perhaps? Actually I think it's the fire animation that need to be blocked as mentioned above API are keeping my player equipped on pick up to avoid firing unequipped. How would I implement a block?
 
Last edited:
When you call StartEquipUnequip(x) you can first call IsAbilityType active. This will allow you to determine what to do based on if that ability is active. You should not need to modify any of the included abilities.
 
Thanks,

I have tested as below more seems the issue is getting more specific it's either either a double press of fire combined any equip button or constant fire down with any equip button - will block equip scroll. Calling is equip is only during the animation phase not actually whilst fire is held down constant that where is locks if you don't hold fire down when equipping or a pick up there is no issue. I tried also experimented with stopping the Use ability useTryStopAbility(Use) as it looks associated with the fire. I have experimented even tried adding condtions to x2 pressed and even pressup to try to revert to relevant animation. I reverted back to how I had it looks like thats the most stable way so far.

I have applied the following as below for 'when fire and equip rifle sword held together' but only during equip phases wont resolve' constant hold of fire' or double press of fire and equip rife or sword whist either equipping to rifle/sword or pick up witch constant fire. I have tested carefully with and without this script and makes a huge deference clicking accidentally on the equip rifle/sword is not an issue now, if only it was resolved constant through fire held down too.
***Unless Im totally going in the wrong direction to what you said supposed to have ticked some field for IsAbilityType as box in the inspector?

var equipUnequip = characterLocomotion.GetAbility<EquipUnequip>();
if (equipUnequip != null)
{
// Equip the ItemSet at index 2 within the ItemSetManager. //
equipUnequip.StartEquipUnequip(1);

}
if (equipUnequip.IsActive)// When equipped attempt to repeat animation (only solves is during equipping phase)
{
characterLocomotion.TryStopAbility(equipUnequip);

}

}
}
}
}
 
Last edited:
I have a saved history of my game so I can go back in stages right to the beginning when its just set up to pin point the exact point.

Having checked;

I added machine gun and axe with some 'new input settings' fairly recently was fine before then and tested version thoroughly to sure. Definitely no freeze while holding fire or any equip button, issue before I made recent changes.

One thing I hadn't considered I have updated and assigned inputs for my stings (button functions) as below;

Under Unity input settings manager assigned these 2 for joystick buttons for weapons.

This was what caused the issue borrowing these type of strings *********

'Equip Fith Item' Assigned to joystickbutton 5 Left Upper trigger adding a value here cause the scenario
'Equip Sixth Item' Assigned to joystickbutton 6 Right upper Trigger seems fine

*********Note finally all resolved*********

I have re-arranged my input choices in the Unity Input manager avoiding 'Equip Fixth Item etc as borrowing this type of string caused the issue
Using 'Action' or 'Lean' unassigned strings is fine. I should really create more input strings. I have tested (also realised this meant all my code needing updating where old prior my string input amendments) and can no longer create the freeze as before all fixed.
 
Last edited:
Glad you are making progress! You can do something similar with the Use ability - when the Use ability is active you should stop the ability from running.

Code:
if (characterLocomotion.IsAbilityTypeActive<Use>()) {
   characterLocomotion.TryStopAbility(characterLocomotion.GetAbility<Use>());
}
 
Thanks I cant believe it was just a simple input set up error I had made. Got the use ability stop/start working too. Main thing all fixed working well no issues. Definitely keeping backups, they prove very useful to back track steps.
 
Last edited:
Top