🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Crystal Swapping End

Published January 29, 2024
Advertisement

I forgot a very necessary implementation last week on the Crystal movement system: trash. We needed a system for the player to be able to discard unwanted crystals. This system’s implementation came in the form of placing a panel object in the bottom right corner of the screen that says “trash”. I am no artist, this can be polished when we have our UI design finalized. When the player wishes to discard a crystal, he will drag the crystal to the trash icon. The ActiveDrag script on the crystal will detect that the trash object is the closest to it and prompt the user that this action will discard the selected crystal. The player is given the option to cancel the deletion, or continue.

Surprisingly, this feature had its own problems when it came to implementing. The Draggables and preplaced crystals work using two different scripts as it was initially easier for me to create a new script than to completely refactor an already existing script and potentially destroy a system. Now, the two scripts are often in need of similar code that I am sometimes able to share on the CrystalManagement script, other times it can be a chore, however. One issue that I ran into was an issue with detecting how many slots are filled with crystals. What I found was that there was no issue in the algorithm for counting the filled slots, but rather, the algorithm needed to run at the end of the frame, rather than where it had sat in the code. Certain members had not updated by the time the algorithm ran due to Unity. The fix was to call the method in a coroutine after yield return new WaitForEndOfFrame.

I would have continued on systems by implementing the Supercharge system, but my progress is halted due to the branch needing reviewed. This only puts me slightly behind, and, if the Supercharge system works next week, I will be on target.

0 likes 0 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!
Advertisement