Raycast based melee detection

ashulgach

New member
By default, the swinging of swords and knives feels very inconsistent, with the crosshair not really being an indicator of where an enemy will be hit. Sometimes my swings are going through the wall, with hit detection being inconsistent with each swing. I also increased the hit collider on the weapon because I want the detection to be from a few feet away. This doesn't work because with a very tall collider the collision can detect any object in its swinging path, making combat feel clunky.

Is there a way to have the hit detection be more consistent with having the distance to hit an enemy greater, let's say 4-5 feet?
 

Attachments

  • WeaponLength.JPG
    WeaponLength.JPG
    109 KB · Views: 2
I'd imagine the reason for the awkward feeling is that the hit collider is attached to the weapon itself, so it will move and rotate exactly with the weapon, whereas what you might want instead is a simple fixed collider that extends a certain distance from the character and doesn't move and rotate along with the attack animation. So you could try changing the collider used by the MeleeWeapon component (in the First/ThirdPersonMeleeWeaponProperties components) to a stationary one.
 
The hit collider is indeed attached to the weapon itself because that's how it was set up in the video. I didn't know you could change that to be fixed. Sweet! How do you assign a static collider when the root and all child objects are animating? There's no part that is static allowing me to place a stationary collider.
 
You can assign any collider within the First/Third Person Melee Item Properties component. You could then assign it to a collider that is just the child of the character itself.
 
Top