Creating a Laser Effect (similar to bullet)

Hello, I’m currently working on a personal project to mess around since I took a course last semester that utilized this game engine. This is a space/flying shooter btw.

Short list of what I have at the moment:

HUD similar to Counter-Strike, but tailored towards a space shooter.
A basic open world using the terrain editor (including water and skybox).
Keybinds needed to “fire” a weapon.

The game is in first-person and I am trying to create a laser effect whenever I fire my weapon. I know how to create particle effects such as an explosion of an enemy when destroyed (and similar effects), but I have no clue how I would create a “shooting effect” that disappears with distance whether it be a laser, rocket, etc. Admittedly I am a bit tired and will be taking a nap which will likely turn into a deep sleep minutes after this posting but figured I would post so I have some information to work off of since it does not seem any of the tutorials cover this type of topic. Any help is appreciated!

Well you could actually make a post effect to do it like in Star Wars :slight_smile: Probably a lot of uniforms to update though. You could also just use an object (not necessarily physics-enabled) like in the TestWalkingChar.

I agree with Normen. A simple object with some glow color / blooming may give you what you seek.
Very easy to setup, just follow the tutorials :wink:

Take a look at the physics tutorials - especially the one with walls/towers where you fire canonballs at them.

That might give some inspiration :slight_smile:

It depends on what actual effect you want though - i.e. do you really want a laser (continuous beam) or do you want a projectile of some kind?

Thanks for all of the suggestions. I believe the Hello Physics tutorial paired with the Bloom and Glow has what I want, sorry for not checking it out first. I’ll be creating a projectile laser rather than a continuous beam (think Star Fox 64 or Star Wars).

Alright, so I have a basic projectile working. Decided to switch from Rays to firing a physical object for now and will work on turning this ball into a laser. Have a little issue when firing a projectile while the camera is moving, though. If I am moving the camera using q,w,a,s, or d then the projectile will not be centered when fired. Not exactly sure what is causing the non-centered projectile if anyone has a tutorial or advice that will show me what is wrong.

It sounds like the laser is being created/called, with one position, and then never updated. My suggestion would be to create a method that is used in your update loop that only activates when the laser is active. The method would then update the position of the laser based on player movement.

Did that help at all?

I actually meant that it is not centered if I use q,z, a, or d. Using w, s, or simply moving the mouse alone keeps the laser centered so I do not believe updating the laser is an issue since I created it using a bloom and glow effect sphere. I was actually thinking about switching over to rays, then just creating an effect to simulate the ray or something, but not sure which method would be better for optimization.

Ah, okay. I might be able to help more, but I’d need your code.

I would probably create a version of both, then scale them up (say a thousand of each case) and see which is better.

Cool I’ll try and post my code up sometime in the near future. I’m working on creating a few objects in the world that will explode when hit by the laser at the moment. Once I’m done with that I’ll attach a file of everything I have so it’s easier for people to give advice. Will likely update this tomorrow night.

Sounds good, I’ll check back then.

Attached a link to download the file for the project I’m working on. If it doesn’t work let me know as I am new to Dropbox and don’t fully understand how it works yet. Hopefully you should just be able to open up JME and open existing projects after extracting it.

I have a game world, enemies (four big spheres), HUD, weapon that shoots spheres w/ bloom and glow effect, and collision listeners. The weapon isn’t working how I want it to at the moment. If one of the projectiles collide then it removes all existing weapon projectiles from the game world rather than the specific projectile. Fairly easy fix with arrays I believe, but haven’t tried it out yet.

Current plan is to fix the weapon projectiles so all are not removed upon collision of a single one. Next I’ll create a basic explosion effect when the projectile collides with either terrain or an enemy. After that I’ll create the AI for the enemies so they are flying in the air. I will probably create a custom mesh box to place around the world so that I can create a boundary around the playing field. Hopefully complete all of that by January 14th (start of classes) and then I’ll be working on this a lot less due to school. During that time I want to start messing around in Blender or some type of graphical software in order to update all of the models (HUD, enemies, explosion effect, etc) and spice up the graphics a bit. Then I’ll finally fix up the character control and move on to creating a bigger game world.

Any advice is appreciated of course.