Chromatic Galaxy, new Laser beam weapon and damage scripting

posted in Chromatic Galaxy
Published December 04, 2022
Advertisement

The last days I worked on implementing a new laser beam weapon. The old one was burst fire, the new one is a constant beam that deals less damage. I also implemented damage dealing for both of the laser beam weapons. This was not implemented until now, also added energy consumption for every weapon and general energy regeneration. I will show the details of implementing this below, but first here is a video of the result (I show the old burst fire beam as well):

Fortunately I could just reuse the same shader that I already made for the laser burst. I just changed few variables and made a different texture, also used different values in the line renderer this time. I tested around a bit and ended up using this texture:

In the video this might not be visible very well, but these small dots around the beam in the middle add a little additional effect to the beam as it looks like little particles are flying alongside it. In the game it is a bit easier to notice.

As mentioned above the laser beams did not deal damage to enemy ships, this still had to be implemented. I wasn't sure what's the best way to do it, I ended up adding a collider set as trigger at the end of the beam. The end of the beam is defined by the variables that I apply to the line renderer:

the index 1 is set by script via raycasting. I shoot out a raycast and the index 1 will be set based on the position of the corresponding collision. Probably I could have already used this raycast somehow to also inflict the damage, but I faced many issues with tags and layers at this point and had to rework some older code to make it work at all. It became very clear to me that I didn't put enough thought into making a good concept that I could build up on later. But I guess sometimes you just need to rework older code, creating a game is a progress and new ideas might come during development, so I feel like I can't plan everything ahead of time.

I think the shield shader that I created several months ago still holds up pretty well with the collisions that are going on in the video, but it will probably also need a rework at some point. The AI script that I created for small fighters was used in the video also for the bigger ship. It kind of works but unfortunately for the bigger ships I need to implement something else. The movement style of the bigger ships is just too different from the small ones because they turn around much slower. This way these bigger ships will end up colliding with objects a lot.

0 likes 1 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement