Hey there,
I’ve been designing a third person game and have never gotten the melee system to work properly… When the character goes for a melee hit, i ray trace to find the actor in front of the player, then call aactor->TakeDamage() if the ray trace returns a hit. This works and successfully kills enemy players when they are idle or running around, but if they are shooting you or anything else, the melee attack is rendered useless, and the take damage function returns 1.0 for total damage given.
I have done some digging in, and made sure that i am attacking the right object (for example, ray tracing the weapon actor the player is holding instead of the owning pawn) and making sure I’m dealing the correct amount of damage but still no luck!
Hoping someone has had a similar problem and can share some insight!
Could it be that the ray trace is being blocked by the projectiles the enemy is shooting?
Although I want to say that ray tracing for melee hits feels wrong for me, maybe its right for your game, hard to know without knowing more about your design. Personally I would be using colliders and overlaps to resolve melee combat damage.
I have had results where the ray trace locks on to bullet casing actors or projectiles being firing, but i check the hit actor with every hit, and even when its targeting the correct pawn it still never deals any damage. To be more specific i use a sweep hit to check a large radius in front of the character. But agreeing with you, it dosent feel right. The trace will be blocked by the first thing it hits and thats not what i want. I will do some more work and try adding a collision sphere to the player character.