OnHeal Event Issue

serenity

Member
I think there is an issue with the OnHeal Event mentioned on following page, it doesn't get called when I use the health pack even though the health bar increases and character gets healed.


The OnHealthDamage, OnDeath, and even OnObjectImpact events all work and gets called correctly. The only issue is the OnHeal Event even though I have it in the same script. Can you double check that?

Note: Also the example code has couple issues if you like to fix them in the above linked page:

C#:
Debug.Log("The object was healed with " + amount + " health."}
There should be ) instead of } at the end

C#:
EventHandler.RegisterEvent<Vector3, Vector3, GameObject>(character, "OnDeath", OnDeath);
I think character should be gameObject instead
 
I had the wrong event name in the docs - it should be OnHealthHeal. When you make that change it should work :)
 
I think there is a minor bug still on OnDamageHeal Event:

When you have shield enabled the event returns only the amount healed to the shield. For examples:

If your health is 40 and your shield is 0 and you pickup a 40 healthpack the event will return 0 as healed amount although the health bar will reflect actual healed amount.
If your health is 80 and your shield is 0 and you pickup a 40 healthpack the event will return 20
 
Good catch. We are very close to releasing version 2.2 and I'll have it fixed in this version.
 
Ok great but in my opinions its better to have to heal events maybe an OnHealthHeal and a OnShieldHeal to better tap into whats going on with health
 
Sorry to bring this thread back but I am getting the same issue I think. But the debug log says: The object was healed with 0 health
The whole script is:
Code:
using UnityEngine;
using Opsive.Shared.Events;

public class Heal : MonoBehaviour
{

    public void Awake()
    {
        EventHandler.RegisterEvent<float>(gameObject, "OnHealthHeal", OnHeal);
    }

    
    /// The object has been healed.
    /// </summary>
    /// <param name="amount">The amount of health that the object was healed by.</param>
    private void OnHeal(float amount)
    {
        Debug.Log("The object was healed with " + amount + " health.");

    }

}

The code was from the document.

Since I'm talking about health the health pickup gets picked up regardless of full health or not. I'm using the latest ultimate Controller.
 
There is a checkbox in the inspector for the healthpickup that says something like "always pickup" maybe its ticked?
 
Try using the HealthPick Prefab that is in Demo Folder and try picking it up directly.
See if the issue happens with it as well
 
It probably has to do with the Shield interfering with it as I posted before.
Try disabling shield attribute and see.
If this fails maybe Justin can offer a better solution
 
It probably has to do with the Shield interfering with it as I posted before.
Try disabling shield attribute and see.
If this fails maybe Justin can offer a better solution
Nah I think 2.2 has a bug in it cos the other version didn't do this.
 
Good catch. Health.Heal should have:

Code:
            // Don't play any effects if the object wasn't healed.
            if (healAmount == 0) {
                return false;
            }

Instead of:
Code:
            // Don't play any effects if the object wasn't healed.
            if (healAmount > 0) {
                return false;
            }
 
Good catch. Health.Heal should have:

Code:
            // Don't play any effects if the object wasn't healed.
            if (healAmount == 0) {
                return false;
            }

Instead of:
Code:
            // Don't play any effects if the object wasn't healed.
            if (healAmount > 0) {
                return false;
            }
Thank you that worked.
 
Top