Just about two hours ago, my player character’s sword hitbox that’s being line traced, just stopped wanting to generate a hit event on the enemy pawn. I’ve tried everything in my power to figure out what was wrong, but nothing’s worked. The weird part is that everything is exactly the same way I left it back when it was working.
If anybody has any ideas as to what is going wrong, or what I’m doing wrong, please let me know. **All help is greatly appreciated, sooner than later is preferred though!
** Player’s Line Tracing + Object Type:
Any error message shown up in the editor after playing?
bIsTracing is actually true?
Does the trace returns a valid HitResult?
Can be a lot of things, but since you had it working before and suddenly its not, probably an error message would tell you if something is being accessed incorrectly.
Try debugging every step from the Raycast to when damage is processed
I don’t get an error message, and bIsTracing is true (only when AnimNotify BeginTrace is cued does it set it to true, and when AnimNotify EndTrace is cued, it sets bIsTracing to false, and those both work properly), but I don’t seem to be getting a valid HitResult when it collides with the enemy pawn, but I’m not sure why it isn’t. It’s tracing for pawn objects, and I have my enemy’s capsule collision set to pawn by default, it could be an issue with the enemy’s collision type but I’m not sure.
Alright, it looks like it’s only line-tracing 1 point, where the sword starts the ark of the swing. Which again, is odd because it would line trace the beginning point of the ark, and the end point of the ark. Here’s what it looks like.
Are you sure the forward vector(X axis) for the box is aiming in the correct direction for the whole duration of the animation? Your raycasting code looks perfectly fine, so I don’t think it’s that. It could be is your boolean getting flipped on/off at the wrong times, but I don’t know how you are driving it. Maybe it’s bugging out when the animation is made to play again before it completed the previous loop and is breaking the variable. It could also be an issue in whatever code you have after the hit result. This is one of those test questions where the answer is “Not enough information.”
Try this: set the ray distance sort of short like 100 units and set it to fire on tick. Make sure that it’s flowing correctly; throughout the whole animation. If that’s working as intended, then pay attention to the hit actor; as GBR said. If the ray casting isn’t working, then analyze whatever logic you’re using to drive the boolean.
Alright I tried what you suggested, and I got this, so there’s definitely something wrong with the direction that it’s tracing, but I’m not sure how to fix it
Alright I rotated it to the right direction with the x-axis facing left, but I still have another issue where it doesn’t seem to always actually hit the enemy, as demonstrated in the video below.
EDIT again: I see the red squares indicating that it is definitely hitting the mob.
Set up a debug print string and print out the hit actor to make sure.
Also, how are you actually trying to implement the hitscanning? Do you intentionally want it coming in perpendicularly with the blade like that, or do you want it running parallel with the blade and casting a few rays per swing? I never asked that and it makes a big difference in the x axis stuff that I mentioned earlier.
It’s definitely hitting it on some occasions, and is printing the hit actors name when it does hit, but I think the main issue now is the one IronicParadox pointed out. Where it’s hitscanning perpendicular to the sword’s blade, whereas I wanted it to be parallel to it. And I tried extending the time it has to trace into the recovery, and it didn’t have any effect.
When adjusting the rotation of a component attached to something and it includes animation, I usually add an arrow component attached to the point (your Box component), leave the animation playing in loop inside the blueprint editor Viewport and hit Simulation button. It will visually indicates you the forward direction of the component.
If you want to make a “Slash” trail simulation, I suggest you to have multiple* line traces every call. Tracing isn’t expensive, so no need to worry about performance in this case.
1 parallel trace over the sword mesh and 2 or 3 perpendicular with given past end points that can be stored in an array, for example.