Overlapping item pick ups not updating? (UCC 2.1.10)

zambii

New member
Hello, so I have two ItemPickUp abilities because I want the player to be able to pick up weapons with a specific button and the ammo with another. I also require the player to currently have the weapon that the ammo belongs to in order to pick up the ammo (i.e. must have a pistol to pick up pistol ammo).

So far it works, but my problem comes when the pick ups are overlapping. WeaponCase.png
As you can see I have the weapons and their respective ammo in cases, but when I pick up the weapon, it seems like the ammo pick-up ability does not get updated. I have to get away from the item pick up and try again and then it will work. Any idea why?

I think it's because I am required to exit the trigger zone and enter it again but if that is the case, then how could I force an update? Am I wrong to have two separate pick-up abilities? I attached the object's hierarchy in case it helps.
 

Attachments

  • WeaponCaseHierarchy.png
    WeaponCaseHierarchy.png
    7.3 KB · Views: 1
I would have a single pickup ability that can detect both triggers and do a raycast. This should then allow it to better detect both pickups.
 
I would have a single pickup ability that can detect both triggers and do a raycast. This should then allow it to better detect both pickups.
The thing is I require a specific input to pick up weapons and a different one for ammo, having one ability would not allow that right?
Also if it is one ability it will force the player to pick up items by order of detection rather than by optional choice right (i.e. if it detected the weapon before the ammo and the player wants to pick up the ammo, the player would be forced to take the weapon first and then the ammo)?
 
How are you checking that the player has the required item for picking up ammo?

I'm assuming you're using the trigger detection mode for the ItemPickup ability - you could try using a different one instead, as I believe that mode works on OnTriggerEnter/OnTriggerExit. Spherecast is a good option for low performance costs.
 
How are you checking that the player has the required item for picking up ammo?

I'm assuming you're using the trigger detection mode for the ItemPickup ability - you could try using a different one instead, as I believe that mode works on OnTriggerEnter/OnTriggerExit. Spherecast is a good option for low performance costs.
Yes, I am using trigger detection. So the other modes will be updated every frame? or only while the character moves like all other abilities?
 
Spherecast will perform the spherecast whenever the ability tries to be started, i.e. when you press the input key.
 
Spherecast will perform the spherecast whenever the ability tries to be started, i.e. when you press the input key.
That is good to know, however, I did get it to work with another method. I had both abilities detect the same layers, so I separated the item pick-ups, one to one layer and the other to a different layer and now they get detected properly and have no issues. So I'll consider this done but I'd like to post my explanation in case there are further questions or someone else has the situation and sees this post.

I think the main problem was, not that it wasn't "Updating" which I think it still doesn't due to using the trigger detection method which works with OnTrigerEnter and OnTriggerExit as you mentioned previously, but that no longer creates a problem because now the detected pickups are not being obscured by the wrong item pick-ups being detected which was probably what created my awkward situation, even though I did get the ability to "Update" by moving inside the triggers after picking up one of the registered items, but probably the reason it wasn't "Updating" is that even though OnTriggerExit was being triggered due to picking up one of the items, it was not updating the other ability's detected items, only the ability that was used to pick that item up, and so that other ability would still think that the item is still there and not picked up which required me to walk outside of the trigger zone and trigger the OnTriggerExit and walk back in to properly update the detected items with the correct items.

I hope that makes sense lol.

Also, I created some layers but they wouldn't show up on the ability's editor, is this due to the custom editor drawing?
 
Glad you sorted out a solution!

I've noticed that restarting Unity is sometimes required for layer lists to update.
 
Top