Mining Laser Advice

Hi all,

Wanted to reach out for some advise on the best way to tackle a Mining Laser Beam. The end result is thhat when the player clicks and holds down the left mouse button a constant laser beam will shoot out towards the center of the screen until the player releases the button.

So far I have both a laser gun and rocket launcher that uses a prefab shot type that instantiates from the proper gun barrel and uses ScreenPointToRay with transform.forward to launch the shot types forward to the center of the screen. Of course the mining laser is what I am stuck on because its a bit different. I tried a few different settings on a trail render but couldnt find a setting that worked like I wanted.

In the end I would like the laser to appear no matter what, just like the other guns, but when it does hit something like an asteroid I can can still use a particle effect at the collision point to give it more of a feeling of hitting something. I have seen the video at Recorded Video Sessions on Graphics - Unity Learn which goes over shooting lasers which is fairly close and most likely the direction to take but wanted to see if anyone has discovered any better ways to do this sort of thing

If anyone has any ideas on the best path to take on this type of thing it would be much appreciated, thanks!

I’ve used everything from LineRenderer’s to Meshes to Particle effects, to third party assets like the Arc Rays whatever. It just comes down to what works best for you, I saw no real differences between any of them.

Creating meshes based on a raycast check is what I liked the best and found the most fluid.

2 Likes

Activating a cylinder mesh when the laser fires is the easiest way. Then just use the usual raycast ScreenPointToRay and spawn a particle effect where it hits.

There’s a trick to making the laser scale to the distance of the raycast. If you make an empty gameobject at the base of the cylinder, you can parent the cylinder to it, so the empty gameobject is now the pivot point. Now you can scale the empty gameobject and the number will be the exact distance/size of the laser.

2 Likes

I’ll have to give these a try. So far I just used the line render method from the Fun with lasers video with a particle effect at the hit point. It works of course, but since its my first time creating a project in Unity I like to explode as many ways as possible to do the same thing so I can find what I like the best.

I appreciate the input!