Week 4

Lauren Frazier
Crab King VR
Published in
2 min readJul 12, 2017

Crab King VR is coming along nicely. This week I worked on the UI and added multiple scenes. The UI was challenging at first but I got the hang of it. I think my background as a mobile developer helped me to figure it out.

I bought a health bar set called Health and Progress Bars Pro and integrated it into the game. For the enemy, I added a Canvas child, then added a HorizontalHex bar to it. I added a Text child to the HorizontalHex, and that’s where the name is set. I edited the Enemy script to allow the Enemy to set its own name, and when an attack is received, it edits the bar’s value.

I then worked on the player’s health bar. This proved a bit more challenging. While the enemy health bar is attached to the enemy, the player health bar is anchored to the top right corner of the screen (screen space vs. world space). That was fairly simple to figure out, and I ended up adding a canvas and health bar to the Player GameObject. I did the same thing as the enemy bar, adding text that just says “Player” for now. Once I choose a name for the female crab, I’ll replace that text. The hard part came from figuring out how to adjust the health bar’s value when damage is taken.

Originally, I tried an approach using UnityEvents, but I couldn’t get it working. I settled on adding a public method in the Player class, then calling it whenever the _health value updated in the BS_Main_Health script.

The health bars really add to the game and make it feel polished.

I added an Intro scene that is basically a clone of the Main scene, but includes the words “Crab King VR” floating above two buttons, “Start” and “Credits”. Selecting “Credits” just triggers a Debug.Log for now, but selecting “Start” brings the user to the Main scene and spawns a Crab Pawn.

Next week, I want to begin work on integrating the King into the game by setting up his model and crown, and animations.

--

--