GameDevHQ — Day 14 — Building a Better Homing Laser Pt.2

Kurt Noe
2 min readNov 25, 2020

--

Aloha!

Today will be a rather quick blog as development on refining the homing laser mechanics has made progressed but a concrete solution has not been found. The newest method of approaching this problem was to move the method of object detection from out of the lasers themselves and into the player character. This allows there to be a persistent game object that performs the targeting calculations rather than each laser having to perform the calculations as they are created. This method was successful in that the closest target was able to effectively update every time an enemy object got closer to the player. An issue with testing this feature is that every enemy object that was created had the same name, making a serialized field a less effective method for finding out which enemy is currently being targeted. To fix this I created a marker out of a laser disc sprite that would match the stick to any enemy that is the current target.

The marker created for target testing attached to the nearest enemy.

After implementing the marker I tested the behavior of the lasers when there were multiple targets in the scene and found that they performed the same problem as before where there would be a delay after a target enemy is destroyed before the lasers would find a new target. From observing the behavior of the marker as well as the serialized field on the player object that shows the closest target that the script has discovered I found out that two things. The first is that the distance detection function works properly, the second being that main issue comes from the script running into issues that occur when the target is destroyed. This may be due to removing an object from an array of objects which the foreach method of iteration is occurring. As of this writing I do not have an immediate solution but I plan to continue experimenting with possible ways to tackle this problem in the coming days. Until then, mahalo for reading.

— Kurt

--

--

Kurt Noe
Kurt Noe

Written by Kurt Noe

An aspiring game-dev from Hawai’i. Previous experience has been in programming and animation work. Blogging my progress through personal projects and research.

No responses yet