Using Traces for Weapon Bullets

Sorry for the late response.

Yes, it uses line traces and has some rather complex math thrown into it. So it’s not really a hitscan weapon, which might be what you’re looking for. But it takes muzzle velocity, mass of projectile, diameter of projectile and all that stuff into account and even features ricochets.

I think it’s a great system to further improve upon, but I do not know how efficient it is in terms of performance. There should be some videos on youtube if you’re interested.

Edit:

Forgot I had this video, which was me just messing around with it very early.

looks cool… I think I’ve learned enough to recreate that on my own actually… but obviously i donno the depth of it.
The issue though is that its built for FPS… TPS is slighlty different… because those line traces come from the camera not from the gun or character… im guessing that the blueprint youre showing has them coming from the camera as well… just out front x amount of space as the start rather than coming from the socket of the gun specifically.

when doing it that way in a TPS game… the trace goes to the centre of the map… but thats not always the crosshair position… at a great distance it will at some point be the cross hair position…but thats not helpful when aiming obviously. I might check it out none the less though… does it have some bullet effects included?

True, but my point is, if you trace from socket-to-reticle, the bullet (as simulated by a trace) effectively stops RIGHT AT what you want it to hit… what you want is for it to go way THROUGH that point. What I’m saying is, figure out the vector which points forward FROM the socket TOWARD the reticle’s target trace location, and scale that vector up to be whatever you want the bullet’s range to be (60,000 units, say). That way, instead of the game tracing from socket to target, it traces from socket THROUGH the target, which is a much better guarantor that the hit will register. This is especially important if the target is moving when the shot is fired; if the trace is performed before the actors’ locations update, then the trace will trace to where the actor WAS last frame, before the update registers… and possibly miss as a result.

Hey RhythmScript,

Thanks for all your help so far. I think I know what you mean, I tried a few times breaking the vectors but I kept messing up the locations… so i reverted back. If you can maybe give a real example based on my bp attachment… that could help.

Also noticed a new problem. When i shoot the enemy, its quite precise… registers exact bone hit etc… but if i put the crosshair off to the right i can still hit the enemy… because clearly the gun muzzle line of sight goes through the enemy to the crosshair. Any suggestions on how to fix this?


editor.png

400 attemps at getting this right and yours worked thanks man