|
Post by alexmars on Aug 5, 2019 14:11:11 GMT
Hi all I am trying to change sound depending on how much health does character have. I can't send currentHealth to another script. I have created a script to test sending number of current health and it doesn't work. Can you please guide me to sned health points to another scripts.
using System.Collections; using System.Collections.Generic; using UnityEngine; using Invector.vCharacterController;
public class damage_snapshot : MonoBehaviour {
public GameObject character; public vThirdPersonController tpInput; public float Health; void Start() {
Health = tpInput.currentHealth;
}
void Update() { print(Health); } }
Thanks in advance
|
|
|
Post by Invector on Aug 6, 2019 0:36:09 GMT
Your script does work, but since you get the currentHealth only in the Start, it won't be updated. Relocate the line inside the Start method to the Update and it will update the value
|
|
|
Post by tanoshimi2000 on Jul 18, 2023 13:22:26 GMT
(Since this is titled Current Health, I figured I'd post here.)
I'm using Easy Save 3, Auto Save, and I've tried selecting both _currentHealth and CurrentHealth, and neither is working. It's supposed to save the value at exit, and load it next time on Awake, but I'm always getting 100%. I kinda don't want players to be on the brink of death, exit the game, and resume with full health. I see that it's a protected field. Is that what's preventing it from being set?
I believe the Load function takes place in the Awake function, could something else be setting it to 100% in the Start function? I doubt that, because if I manually set the health in the Editor, it persists to the game.
Any suggestions?
|
|