Friday, June 2, 2017

Day 55: Audio-Only Game: Day 30

So, I managed to figure out how to do what I needed without needing an answer on the forum.

My problem, was that I couldn't get the player controller script to access the "Health" variable in the Statistics script on the enemy that was hit. I tried a few different things yesterday, none of which worked. So, instead, I decided to follow a tutorial, and change it as needed.

first, I added a new private "storage" space.

Next, I added 2 lines to the Raycast function.

The second to last line adds the "Statistics" script of the enemy that was hit, to the 'statistics' storage space. The last line accesses the Health variable through the script stored in the storage space. It then sets the Health variable equal to the Health variable minus 50. So 50 health is removed each time.

Next class I will add a variable that changes the damage dealt depending on the weapon. The sword will probably do 35 damage, and the crossbow I'll have at 100 damage.

No comments:

Post a Comment