Hit events are not generated all the time.
I am experimenting with a fps like game in which you have a rifle and shoot a series of standing characters (all inherit from the unreal character class)
I've written a projectile blueprint class which contains a static mesh projectile.
The projectile has its Event Hit event implemented. Which basically deals damage to the hit actor (if it implements Damagable interface) and emits a particle system and a sound for the hit effect and destroys itself.
This works mostly. But some bullets (like 1 in every 10) are reflected (like mirror reflection) from the characters once they hit them. It seems like the physics engine is correctly detecting and handling the bullet hits but the Event Hit is not fired in the editor, so the bullet has no way of destroying itself or dealing damage.
So far I've tried:
I am seriously stuck with this issue. Could you guys suggest me a way of fixing this?
asked Nov 11 '16 at 05:12 PM in Bug Reports
At this point I would determine this to be a precision issue. I put together a projectile system like the one you showed and with a high enough velocity caused the projectile to pass through the target. That is what you are reporting if I'm not mistaken.
I think it's fine predicting the trajectory of the projectile however, I don't think you need to map all the points to a spline and do all that collision checking on tick as you move the projectile along the spline. All you would need to do is run the predict projectile path function, make sure that all objects you want to account for collision are included in the object type list (for example check for the character mesh instead of world static).
It will then trace along the path stepping along the way checking for a hit. The accuracy depends on the sim frequency. You can also increase projectile radius to help fill gaps. It will return a hit in the form of a bool once this trace touches the desired object.
you can use this bool in a following branch node and if true fire a custom event (named hit event if you want). You can just have the actual projectile be visual since you are using the predict projectile path to check for hits.
That way you aren't running the predict projectile path only to run a series of checks again when you move the projectile along the spline generated as this is twice the work. Oh and the sim frequency can be adjusted for performance.
I hope that helps,
answered Nov 16 '16 at 04:21 PM
Thanks for your answer.
I am already using the default Mannequin character from the FPS template.
Up to step 6 we share the exact same setup. But yes I've used the mesh's own collider (without a collision component) to get hit events. However I've tried your collision component option but unfortunately it didnt work as expected either.
To update the mesh using physical simulation, I have to let the skeletal mesh to respond the collisions otherwise the engine gives me an error.
I've tried to disable skeletal mesh from generating hit events (but still updated by physics). And tried both sphere and capsule collision components (both as root of the actor and child of the s.mesh within the actor). Capsule and sphere collision components resolved the issue but with high speed projectiles this time some of the hits are missed entirely (instead of getting reflected from surfaces they pass through). Enabling CCD also did not resolve the issue and I did not want to activate substepping for performance considerations.
Though I've found a better solution to my problem. Whenever I fire a ranged weapon I call the PredictProjectilePath function from the Unreal library. I set Object types to WorldStatic only. This gives me an estimated trajectory of the bullet which considers only static actors. Then I assign the trajectory to a spline component I attached to the projectile actor.
At each Tick (tick times can be configured for performance) event of the projectile, I first accumulate the deltaTime parameter into a shootTime which was initiated to zero when the Shoot function was called. I then sample the next position on the spline at shootTime. And attempt to Move the projectile to the next position (and rotation) with a sweep. If the sweep returns a hit actor and a bone then I call the takeDamage routine of my interface.
This approach effectively solves the high speed bullet collision problem and consistently captures all hit events. It is also configurable through setting the tick interval of the projectile. Basically more ticks = smoother projectile path, less ticks = less sweep querries.
I believe this is a good answer to this question. But I still believe that the missing hit events issue is a bug.
answered Nov 15 '16 at 12:32 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here