top of page

Unity - Hypothetical Code

I've gotten very used to Unity over the past few weeks, yet there is still a lot I'm not sure of how to do. I decided that I would simply go back through my project and check for any errors to become more comfortable with the software.


Since the machine I was working with reset, I had to re-register the project with Unity to work on it. This gave me the time to go through everything right from where I left off. Thankfully everything was the same as how I left it, so I went ahead and decided to make more of the scriptable object I'd named 'Potion Value' and fill in all the information for each of the potions. Unity had remembered that I'd created the scriptable object, so I was able to do this.


Unfortunately, due to my lack of experience with Unity and C#, as well as dwindling time on this unit, I cannot complete my game. Despite this, I'm incredibly proud of myself for doing what I did. Even though coding is not my strong point, I understand some of the logic behind it enough to know what I needed to do, but not how to do it.


Here is a list of all the code I had planned out in my mind, but lacked the knowledge to create:


Potions


The potions needed to be properly assigned values, which I'm sure using scriptable items waasn't entirely the right way to go about it. I would have to have a way to attach the scriptable objects to the objects themselves, and create a script that would read these values and do the calculation for them.


Cauldron


This brings me onto the next point; the cauldron. The cauldron has to be able to register which potion is being dropped into it, which is why I added a collider. This collider could also be used to register what potions are being added. This might require some sort of switch of if statement, but I'm unsure. It may require something else entirely, which is why I'm unsure on how to code this and optimise it.


Result Screen


This leads into the last thing, which is the result screen. I could use a scriptable item in order to easily change the text on the menu according to the results of whatever combination the player chooses. However, this would require the collider to be linked to this, as well as a calculator inside the code to make the results and register the name of the combination made, the score the player got and the potency, which is linked to the score. This would require some variables and a switch statement, but I only say this because I'm unsure of how else to solve the problem.

Comments


bottom of page