Projectiles flies through object

Hi,
I am making a bow with arrows and ran into a problem.

I have an arrowBP, with a static mesh, projectile component and a collision box. When I fire the bow I spawn the arrowBP and set velocity and speed of the ProjComp which makes the arrow fly. When the arrow overlaps with any object the corresponding event is fired, which disables the ProjComp and sets the world location of the arrow.

The problem is: if the speed valriable is too big, then the arrow will fly through the object. If someones fps is lower then 30, then the arrow will fly through 90% of the time.

Probable solution: I need either to make it somehow detect the overlap 100% of the time or make the arrow fly slower, but in the end have the same distance traveled. I dont know how to make any of these.

Does anyone have suggestions or solutions?

Solution: enable physics substepping.

Bonus solution:
Modularly increase the length of the collision box of the projectile based on travel velocity.

Actually do the math. The engine detects X each frame without substep. So to have Y fly at V speed and hit it needs to grow by?

Check that your projectile Static Mesh, has Collision (and is it enabled) (or has a Physics asset attached)

I’m just saying what I would try by the way…

Would make perfect sense if not for the fact the OP stated he’s getting hits about 90% of the time.

Subsstepping doesnt really help at low fps.
I dont understand what your bonus solution supposed to do. Like if the arrow has a high speed then the collision box will be very long? Or it will adjust the collision box each frame depending on the speed?
Something like this:

Arrow mesh doesnt detect the wall. It ignores everything. The collision box as another component in the actor does it

Yes.
By having the collision increase in size you can get the engine to still detect stuff.

The problem / solution all depends on how thick the surface is, vs the size of the collider.
As well as “where” things will be frame after frame while in proximity of the target.

So assuming you have to detect a 1cm thick target with a 2cm bullet that travels at 150m per frame (not second)…
And that the target is at 100m from starting point…

By The second frame the target is already 50m behind.

So in order to find where the hit was you would need to just modify the collision to be 300m longer than 2cm.

Or, just add 150m in front and 150m at the back of the collider (where 150m is really just the speed solved to a distance per frame).

And btw, substepping would work with the same principle - meaning you may need to increase the count of how many times the calculations occur based on what the criteria is.

2 Likes

I solved it with linetraces, thank you for your great suggestion

1 Like