Download

Weapon trace / Destructable object penetration

What would be the best way object penetration?

I added some windows to my game level which are destructable objects, so i can shoot the windows to break them, but i want to be able to shoot “trough” the windows to kill enenies behind them.
So the window should not be stopping my bullet.
Also want this features for other object, including characters (be able to have a multi kill with a single bullet)

Should i make an actor for the window with an OnHit event which starts a new trace? (depending on the angle the window has been shot, it might affect the direction of the bullet)

The way I would go about it is have onhit deal damage to an object and check to see what kind of object it is. After confirming the object type or category apply a change to it’s trajectory(not sure if that’s the correct word to use) and slow it down or change the angle slightly. Whether that works I’m not sure but that’s my two cents on how I would attempt it.

Just don’t kill the projectile when it overlaps something…?

You can keep an array of things the projectile has come into contact with, to ensure it doesn’t count the penetration or deal damage more than once. Create a special collision channel called ‘Penetrating Bullet’ and setup the objects to ‘Overlap’ with that channel but not block it.

If you want objects to behave differently when the projectile hits them, create an interface that provides a function for ‘OnBulletPenetrated’ or something for all objects that react to it.

^

In a nutshell use the overlap event instead of hit event

Maybe i forgot to mention … the question is related to tracing, no projectiles :frowning:

For projectiles i used the overlap already on pawns, so able to shoot trough them and multi-kill.
The OnHit was probably a bad example in my question when it’s about weapon tracing.

You can set which collision channels the trace is performed on…
You are most likely tracing on the visibility channel which would explain why the destructibles are ending the trace.

So you could either set the visibility to “ignored” on the destructible’s collision settings or you can set the trace to be performed on something else than the visibility channel (for example you can trace for pawns only).
Also there is multi trace which returns an array of all the actors that the trace hits but it’s probably best to avoid that one if you can.

Check this:https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/index.html
The Multi Line Trace is maybe what you want. The multi trace hits all the things in its way and returned them.