Post by nerdares on Oct 30, 2016 19:09:12 GMT
In my survival system that I have created, I have made method's in my health method that should take care of : Updating the health bar, Auto Healing during a delay or when hunger/thirst is above 60% & Killing the player when health is 0. I took out these methods in the third person motor and the hud controller because I want these health and stamina properties to rely on my script. Additionally, I also modified the stamina operations in the third person motor and made it work with my vSurvivalPlayer script methods that I have made.
Consequently, that means I have to - in a sense - override the health and stamina values with mine. Not sure if you can override variables but what I did was go to ThirdPersonMotor and go to its Init method. There, I set maxStamina = mySurvivalPlayer.MaxStamina. (mySurvivalPlayer is an instance of a script I made, vSurvivalPlayer). In the UpdateMotorMethod, I set currentStamina = mySurivalPlayer.CurrentStamina. The reason I did this is because I don't want to go to each and every script and change the health and stamina values.
The problem is health. I've got nothing but death to work on it. The issue is, when the player takes damage, currentHealth goes down. But what about mySurvivalPlayer.CurrentHealth? In that case, what I thought I would do is in my vSurvivalPlayer script, I would make CurrentHealth = TPC.currentHealth (TPC is an instance of the thirdpersoncontroller). That doesn't work all the time because in some of my methods, I force CurrentHealth to go down when -- say for instance -- hunger = 0. Now CurrentHealth is going down but what about TPC.currentHealth?
I'm going through a bit of a hassle right now since these values need to synchronize with each other. Right now all I can assume to do is use pointers but that would be ridiculous and dangerous
Consequently, that means I have to - in a sense - override the health and stamina values with mine. Not sure if you can override variables but what I did was go to ThirdPersonMotor and go to its Init method. There, I set maxStamina = mySurvivalPlayer.MaxStamina. (mySurvivalPlayer is an instance of a script I made, vSurvivalPlayer). In the UpdateMotorMethod, I set currentStamina = mySurivalPlayer.CurrentStamina. The reason I did this is because I don't want to go to each and every script and change the health and stamina values.
The problem is health. I've got nothing but death to work on it. The issue is, when the player takes damage, currentHealth goes down. But what about mySurvivalPlayer.CurrentHealth? In that case, what I thought I would do is in my vSurvivalPlayer script, I would make CurrentHealth = TPC.currentHealth (TPC is an instance of the thirdpersoncontroller). That doesn't work all the time because in some of my methods, I force CurrentHealth to go down when -- say for instance -- hunger = 0. Now CurrentHealth is going down but what about TPC.currentHealth?
I'm going through a bit of a hassle right now since these values need to synchronize with each other. Right now all I can assume to do is use pointers but that would be ridiculous and dangerous