wesleywh / EasyMultiplayer-Invector

Where to submit issues for "Easy Multiplayer - Invector" suite of packages that is available via GumRoad or the Unity Asset Store. GUMROAD: https://cyberbulletgames.gumroad.com/ ASSET STORE: https://assetstore.unity.com/publishers/34070
0 stars 0 forks source link

Hold Input Button Bug #27

Closed wesleywh closed 1 year ago

wesleywh commented 2 years ago

Describe the bug Reported by @lorax

found an odd bug. Don't think it is specific to my character controller.
When holding a weapon (vAxe), if i click and hold my client will play the attack animation once.
Other clients will see me continue to attack as long as the button is held.

To Reproduce "Hosted Mode"

  1. Run ShooterInventory scene 2.Pickup Axe
  2. Hold Attack button
  3. Owner client attacks once, everyone else continues to attack

Expected behavior Attacks should be synced with their number of attacks.

Screenshots/YouTube Links

https://www.loom.com/share/923636e20589447ebc5bf3aba077a07d

Versions

wesleywh commented 2 years ago

Confirmed.

wesleywh commented 2 years ago

This is happening because a switch happens when you equip a melee weapon inside the

protected virtual bool DrawWeaponsImmediateConditions()

function that lives in the vDrawHideMeleeWeapons component. I'm suspecting that the melee.weakAttackInput.GetButton() is triggering a reset to be sent to the server every second when the button is held. Not a 100% confirmed yet but I bet the issue lives in the MP_vInput component in the GetButton function.

wesleywh commented 1 year ago

I figured out what is going on. It's going to take a little bit to implement a fix. Basically it is this.

The curBoolValue and prevBoolValue are shared between all methods GetButtonDown, GetButton, GetButtonUp, etc. For certain button presses this is okay but for others, like the WeakAttackInput this MUST be separated out to individual actions. So I made the following new variables:

curHoldBoolValue
curUpBoolValue
curDownBoolValue
prevHoldBoolValue
prevUpBoolValue
prevDownBoolValue

In the MP_vInput component. I also added some additional logic to check for button names with keywords to make sure that down and up buttons are reset properly as with the new setup it will only send to the server on a true result. So the server will need to reset the buttons to a false result to properly work. There is a lot to work through but that's the current issue. I will add a hotfix to the #downloads channel when I have completed my work.

wesleywh commented 1 year ago

This has been resolved and was able to optimized the amount of network calls that take place. I have included a hotfix in the #downloads channel on discord until the next release.