GEOMETRIC BYTES
Member
Hi. I have a problem to cause damage to the player. I do not understand how the system is. I'm not very good with C # yet. Please, could anyone explain me step by step, how could I make an object hurt the player and even kill him instantly? I've already got him to die for a fall, and I've made the ragdoll work. But I have not been able to do this. Thanks.
I'm using this, but it does not do anything:
public class MyObject : MonoBehaviour
{
[Tooltip("The character that has the health component.")]
[SerializeField] protected GameObject m_Character;
/// <summary>
/// Damages and heals the character.
/// </summary>
private void Start()
{
var health = m_Character.GetComponent<Health>();
// Cause 10 damage to the character.
health.Damage(10);
// Heal the character by 10.
health.Heal(10);
// Kill the character.
health.ImmediateDeath();
}
}
I'm using this, but it does not do anything:
public class MyObject : MonoBehaviour
{
[Tooltip("The character that has the health component.")]
[SerializeField] protected GameObject m_Character;
/// <summary>
/// Damages and heals the character.
/// </summary>
private void Start()
{
var health = m_Character.GetComponent<Health>();
// Cause 10 damage to the character.
health.Damage(10);
// Heal the character by 10.
health.Heal(10);
// Kill the character.
health.ImmediateDeath();
}
}