I got a laser sight to work! But I can't despawn it.

I’ve written some code to do a line trace from one location (0,0,0) to wherever a linetrace ends. However, my implementation if it is a little wonky for a couple of reasons:

  1. While the projectile spawns file, it works by using a bad workaround. It deletes the old instance every 1/60th of a second, and remakes another. Because it is only marked for deletion and isn’t actually deleted at every frame, it doesn’t actually follow player movement. My laser actually works in real time, too, so I don’t see why I couldn’t just use one laser and have it constantly on, but only render it at specific points. My issue is getting the laser to actually attach to the physical gun.

  2. The constant addition and deletion is really taxing on the system; I wanted to ask about an implementation on my gun blueprint that doesn’t require constant creation and deletion of the linetrace, but for a way to just have it be constantly on?

Why not just spawn and attach a red, semitransparent cylinder, then update its rotation and scale every tick until you decide to deactivate the laser. In which case, you could hide and unhide instead of spawn and destroy.

Strike that. You could just attach a cylinder to the object producing the laser, turn off collisions so you can trace through, then only update the z scale to match linetrace distance every frame. Hide and unhide as needed (not alternating every frame, just when laseron/laseroff).

That’s 100% what I ended up doing. Thank you so much!