This week I learned how to give Ruby a health status. I added a maxHealth and currentHealth variable to the RubyController script. I made sure that Ruby would have full health at the beginning of the game by adding "currentHealth = maxHeath" in the start function. I added a ChangeHealth function along with the appropriate code that allows the health status to change. I brought a strawberry into my scene as a collectible object that boosts Ruby's health. I applied a box collider to the strawberry and activated "is trigger". I created a new script for the collectible and applied the code that would allow Ruby to collect the strawberry and give her health.
I added a damage zone to my scene and created a script for it. I applied the code that would cause Ruby's health to decrease if she were to come in contact with it. I changed the sleeping mode of Ruby's prefab to "never sleep" and edited the RubyController script so that she will be invincible for a bit while standing in the damage zone. I also introduced an enemy bot, turned it into a prefab, and gave it a script. I added the appropriate code that allows the bot to move back and forth in the scene. I edited the code so that Ruby will take damage when she collides with the enemy.
Comments
Post a Comment