Pickup item w/animation questions/issues

AKB

Member
Hi there.

So, I was having a really hard time getting animations to play when using the PickupItem ability. The item would disappear OK but no animation ID would be set and hence no animations would fire. I found this thread which pointed me in a good direction, such that animations happen now but I have a couple more questions/queries because it's not quite working right.

The solution required me to add an additional EquipUnequip ability with a matching category for the item (I have a Backpack category). Is there a way around this because the items will never actually be equipped, they are just collected and a count displayed in the UI so having an EquipUnequip seems redundant.

The adding of the item to the inventory happens when my animation events fire, which is what I want, however the item is removed from the scene immediately. Can the item be removed when it's actually picked up (Due to the event), not at start of the PickupItem action? This would seem like the right way to do this, correct?

Here's the ItemPickup for it - note there's no related ItemSets etc as it's not an equippable item
1636025036894.png

Thanks
 
The pickup/destroy logic is done by the ObjectPickup class, which ItemPickup inherits from (via ItemPickupBase). So, you could create a custom ItemPickup subclass and override the ObjectPickedUp method, taking out the ObjectPoolBase.Destroy line.

The EquipUnequip ability is required by the Pickup ability. So if you want to completely avoid the use of the EquipUnequip ability, you'd need to do a similar thing here, i.e. override that part of the Pickup logic, which happens in PrepareItemPickup (that method should return false if the item won't/can't be picked up, so you could do some simple logic e.g. checking if the ability is disabled or already active).
 
Thanks Andrew. These could be worthy additions to the plugin to be honest. I can see many cases where you might want to pickup an item AFTER the animation has run its course, and also to be able to do it without the EquipUnequip for items you pickup "physically" (Animated, user driven) but aren't actually equippable. Unless there is some other better system in UCC for non equippable items that I'm not aware of.
 
One thing I didn't even think to mention is that you could also use the animation event on the pickup animation to control when the item is actually picked up. The pickup event should execute an event called "OnAnimatorPickup", and in the Pickup ability you can enable "Wait For Animation Event" under "Pickup Event". This means that DoPickup will only be called when the OnAnimatorPickup event is heard. You can edit the events on an animation clip in its import settings, under "Animation" --> "Events". The demo pickup animations have the two events on the timeline, so you could start by moving them around.
 
Hi Andrew. That's exactly what I was doing - using the animations to drive the pickup. However my issue is that the item gets removed from the scene before it's actually picked up by the event.
1636403753097.png

I expected the pickup and removal of the item to actually happen at the same time.
 
Hm yeah I see what you mean, those two things (the item being added to the inventory, and the item pickup object being destroyed) do happen at 2 different times. The item pickup object is destroyed within ObjectPickup.ObjectPickedUp, so as I suggested before you should be able to just override that method. But I'll pass this on to Justin in case there's an easier way for him to implement this in an update or something
 
Thanks Andrew, it'd be a good feature to have I think. Hopefully I can get to this today and do some testing and see what workaround I can get working.
 
Top