PickupItem ability does not turn off

i have an issue where the pickupItem ability stays on when i press the pickup button, resulting in the character picking up anything it comes into contact with, not the desired behavior of pressing a button to pickup a single item. I see that when i press the pickup button, the CanStartAbility() is called and returns true, and abilities.AbilityMessageCanStart gets set to this, but the ability should be turned off after picking up an item.

This also somehow makes the Ability Index in the animator not get set to 11 which triggers the pickup animation which contains events to call pickup and pickup complete. I've also tried disabling Wait for animation event, but still the same behavior occurs.

Any ideas what the issue may be?

Thanks,
 
What stop type are you using? It should be set to manual and it'll be stopped when the PickupComplete event is sent.
 
Right, that's what I can't seem to locate, where it sets the animation field so that the animation is played, it never sets the ability index and can't find where it is supposed to set that field.
Also, shouldn't the animator not matter if the wait for animation isn't active? because it behaves the same either way.
 
It doesn't sound like the pickup ability is starting at all then. Are you able to tell me how to reproduce it from a fresh project?
 
I can try to reproduce it in a new project today. The items are only picked up when I press the action/pickup key, so it is definitely picking up the objects on key-press, it just doesn't change the animator state for me.

Another thing I've noticed is that when I deactivate the ability (still exists in the ability list but the active checkbox is un-checked) it picks up the items when walking over them without pressing the pickup button, and this is with the items NOT set to pickup on trigger. When i remove the ability completely from the list, it does not pick up the items.

Another note: the AbilityWillStart() function in the PickupItem class is called anytime the DetectObjectAbilityBase detects an object, but AbilityStarted() is never called and DoItemPickup() is never called, which is where
if (!m_PickupCompleteEvent.WaitForAnimationEvent) {
Scheduler.ScheduleFixed(m_PickupCompleteEvent.Duration, PickupComplete);
}
is called

-------------------------EDIT--------------------------
After more troubleshooting I've noticed that inside of the PickupItem AbilityWillStart(), it reaches this section:
var allowEquip = (m_AllowEquippedSlotsMask != (1 << m_Inventory.SlotCount) - 1);
if (!allowEquip) {
// If the item doesn't need to be equipped then it should still be picked up.
m_ItemPickup.DoItemPickup(m_GameObject, m_Inventory, m_SlotID, false, true);
}
return allowEquip;
and returns false. The item is picked up but the ability is not Started. inside of the UCL class, the try start ability never reaches start ability because of the code just mentioned. see here:
if (!ability.AbilityWillStart()) {
return false;
}

so the issue is that the allowEquip is returning false.

I do not have immediate equip on for the item so it seems like since it is not being equipped, the allowEquip is false and thus never starting the ability, but still picking up the items and getting stuck in the state of picking up all items.
I added return true above this logic because i always want to pick up the items without equipping, and now it seems that it is working properly.
 
Last edited:
Top