Location Location Location

*Note for State of Hawaii admin: Medium did not allow this post to be published on the day it was written, December 2, 2020. For documentation purposes, I posted on my website: https://kristinthedeveloper.com/2020/12/02/location-location-location/

We left off yesterday with the health collectible adding infinite lives to the player. Since the if statement in the player script didn’t work to limit lives, I tried using Mathf.Clamp and also if lives > 3, then lives =3…. still unsuccessful. I put a debug.Log message in the player script for to see when the lives were more than three.

Debug.Log() reveals all….HealthBoost is the nectar of immortality.

Thanks to the Debug.Log() message, I knew that :

  1. Health Boost’s collider and rigid body was working
  2. Something was overriding the Destroy.this.gameobject in the powerup script
  3. Mathf.Clamp was either not being called over being overridden by other script.

My next issue was turning off player damage when the player was healed, limiting lives my health powerup could add (max 3) and being destroyed after adding a life. After getting help from Ryan, he reminded me that I needed to be mindful of where I was putting my code- if you attach the if code for those things in the destroy method, it’s only going to get called upon void destroy. Simply moving the code to where it needs to go is the answer. My code wasn’t being overridden, it just wasn’t being called. Thus, all the code was for the health powerup, so I needed to put it in the method controlling what happens during the health powerup being activated. Correct code, incorrect location.

HealthBoost’s code lives where HealthBoost is called. HealthBoost does not live in Player Damage.

I really wanted to figure out as much on my own as possible. After spending so much time trying to this out, I realized that being confused isn’t helping me learn either- especially when there are people there who can help move things along. I’ve heard about this judgement that Jr. Developers have to master- when to ask for help. Only thing is, I’m not a Jr. Developer right now- I’m learning. Interns have been advised to work on something you can’t figure out for 15 minutes, and if you can’t figure it out (step away for a bit to recoup), and then if 15 minutes later, you still can’t get it, ask for help. How do you know what’s the line between trying to learn it on your own vs being spoon fed? What I can tell you is that I did learn the code I needed. However, my ability to recall the info I needed at that time(being mindful of the function location) was the furthest thing from my mind. Unless a fresh set of eyes brought that up, I can’t say how useful I would have seeing it on my own. I wish I was faster at recalling this info I retained. If I understand it and it makes sense, why hasn’t it moved into my working memory yet? We shall see. There is a specified amount of time until this internship is over and I have to be employable….😑. We shall see.

On the upside, I’ve completed two of the eight requirements for Phase I of the 2D course: Thrusters and Health Collectible. I kept working after hours and I’m very lucky and grateful that Dan volunteered to help me see that I was using incorrect syntax with calling a variable. I learned that there is a difference between gameObject, GameObject, transform and Transform. And when you declare a certain variable, you have to initialize in a specific way for that way (if you use Transform you can’t use the same initization for GameObject). I will continue working on my shields color change and limiting my ammo tomorrow.

Stay well friends,

Kristin

--

--

--

Astrologer turned Software Developer who is aiming for the stars to land on the moon. Kristin the Developer is the Celestial Sleuth.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Self-hosting your VSCode online IDE, from Raspberry Pi 4 to AWS Graviton2

Continuous Deployment of Android Apps with CircleCI Tutorial, Part 1

Essential skills for Full stack developers in 2021

Essential soft skills for a full stack developer

Student Spotlight: Building Something for the World with Josh Archer

Using Lego to show the advantages of an Agile approach to software development

Becoming a High-Performance Software Engineer

Part 2: How to stop me harvesting credit card numbers and passwords from your site

Wait A Minute Mr. Postman — An introduction to Postman

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kristin

Kristin

Astrologer turned Software Developer who is aiming for the stars to land on the moon. Kristin the Developer is the Celestial Sleuth.

More from Medium

Patience, word full of blessings

After Flatiron

Hollywood Dreams

EARN MONEY BY WRITING NOVEL