Day 11

Frankie Rodriguez
3 min readNov 24, 2020

--

Stress via Google Images

Today I worked on a few things such as coding for Speed Boost, Shield; and learning to write out checks.

Speed Boost & Shield Power Ups:

  • Just like the Triple Shot, I start to build the components required for Speed Boost/Shield to work. I began by dragging the speed boost/shield sprite to the hierarchy. Once I did that, a thought occurred — will I need to start a whole new script for a powerup that functions similar to an existing one, i.e. triple shot? The answer — no. Instead, I created multiple power up functions within a single power up script and defined the specific power up, which was done by creating a logic. To do so, I created pseudo-codes for each power up i.e.:

//ID = powerups, //0 = Triple Shot, //1 = Speed Boost, //2 = Shield

  • To create the code for each specific power up, I created a privateintpowerupID. Next I serializeField, to be able to see in the inspector. Next I wanted to stimulate the power ups. To do so, I created else if() statements. Below is the code for all the powerups.

How to Write Out Multiple Checks:

  • Like I mentioned above, multiple functions can be written in a single script, however that can become very clustered and disorganized. Instead of having 30–50 else if () statements, I used the keyword: SWITCH. Switch statements, like else if()statements, utilizes () & {}. Switch statements allow me to switch through variables. For my needs, I used switch statements to go through each powerup. I then added breaks at the end of each case (powerup)to let the system know where that specific powerup ends. See my example below.

What are Debug.Logs? In simplest terms, debug.logs lets the developer know within the console (via Unity), that the variable was activated. Once the codes for each specific power ups have been created, debug.logs are removed.

Things that went wrong:

  • So my biggest challenge today was determining why my power up variables (Speed Boost and Shield) were not activating when the debug.logs are in place. I will be working through this problem tonight and will definitely provide a follow-up in my next blog. I will also be reaching out to my team, back-tracking through the videos and comparing it side-by-side to my codes.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Frankie Rodriguez
Frankie Rodriguez

No responses yet