Unequip problem

Absent83

Member
Hallo!

I have a problem with weapon unequipping and as a result with weapon switching.

I have a first-person-character in my project and several new ItemTypes, cloned from pistol and assault rifle with their sub-state machines in hands controller (also was copied from original).

When I unequip a pistol, an animation plays and stops at the end position, but when I unequip a rifle, an animation plays, but weapon disappears and the end position.

The same happens when I swich weapon to the next or previous: after pistol new weapon appears automatically, but after rifle I shoud press buttom “T” twice to make next weapon visible.

Do you have any idea what is wrong?

You can see such behavior in the next video, when I at first press «Т» to show how uneqiup works on current weapon and then press “E” to switch weapon to the next. You can see, that after both pistols next weapon shows automatically, but after rifles there is a problem.

Also in the video I show settings of the item and controller.


Thank you!
 
The animator doesn't update correctly when there is no first person body so that's likely the cause. I have this fixed and it'll be available in the next version that'll be out early next week.
 
Log of toggle equip (UCC 2.0.5):

Pistol
Run game:

1 Changed Slot0ItemID to 201.
Pistol is equipped.
Press T
192 Changed Slot0ItemStateIndex to 5.
Execute OnAnimatorItemUnequip
Execute OnAnimatorItemUnequipComplete
232 Changed Slot0ItemStateIndex to 1.
232 Changed Slot0ItemID to 0.
Weapon is visible and in the bottom position.

Press T
669 Changed Slot0ItemStateIndex to 4.
669 Changed Slot0ItemID to 201.
Execute OnAnimatorItemEquip
Execute OnAnimatorItemEquipComplete
717 Changed Slot0ItemStateIndex to 1.
Weapon is visible and in the top position.
Stop game




Rifle
Run game:

1 Changed Slot0ItemID to 203.
Rifle is equipped.
Press T
192 Changed Slot0ItemStateIndex to 5.
Execute OnAnimatorItemUnequip
208 Changed Slot0ItemStateIndex to 1.
208 Changed Slot0ItemID to 0.
Weapon moves down and disappears in the bottom position.
Weapon is invisible

Press T
Weapon appears
and moves up.
324 Changed Slot0ItemStateIndex to 4.
324 Changed Slot0ItemID to 203.
Execute OnAnimatorItemEquip
Execute OnAnimatorItemEquip
324 Changed Slot0ItemStateIndex to 1.
Weapon is visible and in the top position.

Stop game
 
Last edited:
Log of weapon switching (UCC 2.0.5)

Run game
1 Changed Slot0ItemID to 201.
Pistol is equipped and visible.
Press E
159 Changed Slot0ItemStateIndex to 5.
Execute OnAnimatorItemUnequip
Execute OnAnimatorItemUnequipComplete
203 Changed Slot0ItemStateIndex to 4.
203 Changed Slot0ItemID to 203.
Execute OnAnimatorItemEquip
Execute OnAnimatorItemEquip
204 Changed Slot0ItemStateIndex to 1.
Rifle is equipped and visible.

Press E
321 Changed Slot0ItemStateIndex to 5.
Execute OnAnimatorItemUnequip
357 Changed Slot0ItemStateIndex to 4.
357 Changed Slot0ItemID to 201.
Rifle moves down and disappear in the bottom.
Weapon is invisible


Press T
950 Changed Slot0ItemStateIndex to 1.
950 Changed Slot0ItemID to 0.
Nothing happens. Weapon is invisible

Press T (second time)
1230 Changed Slot0ItemStateIndex to 4.
1230 Changed Slot0ItemID to 201.
Execute OnAnimatorItemEquip
Execute OnAnimatorItemEquip
Execute OnAnimatorItemEquipComplete
1255 Changed Slot0ItemStateIndex to 1.
Pistol appears and equip.
 
Last edited:
Hallo, Justin!

I have worked with other parts of UCC, so this question was paused. Now I need to continue discussion.

So the problem was described in my previous messages and video. Here are settings of my items.

What additional information do you need? Please help to repair weapon switching!

Thank you!

My character has 5 Items.
1544712293783.png1544712308087.png

All items have:
1544712322209.png

1544712328022.png

And corresponding animations have:
1544712339124.png

1544712345090.png

1544712352286.png

1544712358053.png
 
Last edited:
Your Unequip events aren't using animation events so I would clear those animation events out. Is it just a specific weapon that is having issues?
 
I found a mistake. My ItemSetManager was empty :(
Now I fill it with my ItemTypes and in the case without "wait for animations events" everything is OK.
1544736283989.png

But when I check "wait for animation event" for both equip and unequip for all weapons

1544736486224.png

1544736501503.png

i have found, that uneqip animation on all weapons stops (breaks / halts) after "OnAnimatorItemUnequip" event.

And in this case i also have a problem with weapons switching.

But also I have found a hack, when two events "OnAnimatorItemUnequip" and "OnAnimatorItemUnequipComplete" locate very near (close) to each other (almost in one frame), event "OnAnimatorItemUnequipComplete" also occurs and weapons swithch!

Unity 2018.2.19f1 (64-bit)
UCC v.2.0.5
First Person View Character without body (only with hands)


Thank you!
 
Last edited:
If you place a breakpoint within EquipUnequip.ItemUnequip does it get called? What about EquipUnequip.ItemUnequipComplete?
 
Justin, I am sorry, but I have been changing my previous message for a long time and several times and you have answered in that period.
So I do not understand, have you read my last edited message #9?
 
Ah, no, now I see your latest. Glad you're making progress.

If you deselect Wait for Animation Event for equip/unequip does it work correctly? If it does then it doesn't look like the event is being sent from the animator which is why you need two. Placing a breakpoint within EquipUnequip.ItemEquip/ItemUnequip will allow you to verify that the method is being called.
 
Yes, If I deselect Wait for Animation Event for equip/unequip it works correctly.

If I select them "Wait for Animation Event for equip/unequip" i have got all breaks on breakpoints: ItemEquip/ItemEquipComplete and ItemUnequip/ItemUnequipComplete.

But the breakpoint "ItemUnequipComplete" breaks game only when this event locate very near (close) to the event ItemUnequip (almost in one frame).

And in this case (very close location of ItemUnequip and ItemUnequipComplete event swithing is wokring fine, as I told in previous message #9.

Unity 2018.2.19f1 (64-bit)
UCC v.2.0.5
First Person View Character without body (only with hands)




WORK:
1544741693521.png

Do not work:
1544741619747.png
 
It doesn't sound like the event is being sent when it is near 0:42. Unfortunately I don't have any control over that aspect so if you can create a small repro scene and send it to Unity I'm sure they'd love to fix it.
 
I mean in my previous post, that event "ItemUnequip" sent normally. And the breakpoint EquipUnequip.ItemUnequip breaks in any conditions.
But after this event ("ItemUnequip") animation suddenly stops. So animation do not have opponunity to sent next event "ItemUnequipComplete".

I don`t sure that it is a Unity problem, because of ItemEquip/ItemEquipComplete work normally.

So I creacte a repo scene and send it to you by private message.

Here are settings in spoiler.
Unity 2018.2.19f1 (64-bit)
UCC v.2.0.6
First Person View Character without body (only with hands)



1544785185200.png

1544785196202.png

1544785209417.png

1544785222010.png

1544785230554.png

For all weapons (pistol and rifle):
1544785239360.png

1544785245571.png

1544785254308.png

1544785262080.png
 
Last edited:
Thank you for sending the clear repro scene. When OnAnimatorItemUnequip is called the first person arms gets deactivated which prevents the OnAnimatorItemUnequipComplete event from being sent because the arms animator is also deactivated. The transition from unequip to unequip complete is meant so the arms can get back into normal position but with just the first person arms you don't need this. As a result the solution is to either not use an animation event and set the Unequip Complete Event duration to 0 or place the two animation events near each other as you did for the solution that is working.
 
Top