killfrenzy96 / LCThirdPerson

0 stars 0 forks source link

Melee does not work in third person #2

Closed killfrenzy96 closed 1 week ago

killfrenzy96 commented 1 week ago

The shovel (or any other melee attack) does not work correctly in third person. I feel like the melee ray cast may be originating from the camera position, which is often out of range of the enemy.

killfrenzy96 commented 1 week ago

The issue is found within the public void HitShovel(bool cancel = false) function inside the Shovel object.

Within this function, there is this decompiled line: objectsHitByShovel = Physics.SphereCastAll(previousPlayerHeldBy.gameplayCamera.transform.position + previousPlayerHeldBy.gameplayCamera.transform.right * -0.35f, 0.8f, previousPlayerHeldBy.gameplayCamera.transform.forward, 1.5f, shovelMask, QueryTriggerInteraction.Collide);

The shovel max distance is hard coded to 1.5 units. However, I think this may be worked around by patching code just before and after this function is run to reset the gameplayCamera.transform.position value.