Blood-Damage Effect

MissBig

Member
Hi does anyone know how I would integrate https://assetstore.unity.com/packages/tools/particles-effects/blood-damage-effect-9400 I did it for the old UFPS but I'm not sure how with this controller? The way I did it for UFPS is

[SerializeField]
private float damageBloodAmount = 10;
[SerializeField]
private float maxBloodIndication = 0.5f;

at the top of FPPlayerDamageHandler script, serializeField is for it to show up in the inspector. Then in the protected virtual void Update() put in
BleedBehavior.minBloodAmount = maxBloodIndication * (MaxHealth - CurrentHealth) / MaxHealth; at the bottom of the function then in the public override void Damage(vp_DamageInfo damageInfo) and NOT the public override void Damage(float damage) Put BleedBehavior.BloodAmount += Mathf.Clamp01(damageBloodAmount * CurrentHealth / MaxHealth); at the top of the function then put BleedBehavior.minBloodAmount = maxBloodIndication * (MaxHealth - CurrentHealth) / MaxHealth; at the very bottom of the function just before the last }
Put the BleedBehaviour on your weaponcamera. The script is actually BloodOverlay when you click on AddComponent to by the way. When you get hurt it will come up with the damage effect and will also fade out. If you dont want the damage arrows disable the vp_Pain HUD or put no image in the Pain Texture if you want the arrows. Hopefully this helps anyone else and you don't have as much trouble as i had. On the FPPlayerDamageHandler i actually changed the values on damageBloodAmount and maxBloodIndication to 3 and 0.
 

Justin

Administrator
Staff member
I haven't used that asset but for that you'll want to subscribe to the OnObjectImpact impact event:


With the impact you can then run any code which will allow you to spawn any type of effect.
 

MissBig

Member
I haven't used that asset but for that you'll want to subscribe to the OnObjectImpact impact event:


With the impact you can then run any code which will allow you to spawn any type of effect.

Sorry, Justin its actually a screen shader like blood on the player's camera lens. I need it to be like a health flash. It's just a more of a gore effect really. I've used it with UFPS and it has really worked out good.
 

Justin

Administrator
Staff member
In that case I would subscribe to the OnHealthDamage event:


This is a similar concept as OnObjectImpact, except it only occurs when the character takes damage. With this event you can then show the UI.
 

MissBig

Member
In that case I would subscribe to the OnHealthDamage event:


This is a similar concept as OnObjectImpact, except it only occurs when the character takes damage. With this event you can then show the UI.

Thank you so much. It was so much easier to with this controller than the old UFPS. Here is a script if anyone else may find it useful.

Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Opsive.Shared.Events;

public class Blood : MonoBehaviour
{

    [SerializeField]
    private float damageBloodAmount = 3;
    [SerializeField]
    private float maxBloodIndication = 0f;

    public void Awake()
    {
        EventHandler.RegisterEvent<float, Vector3, Vector3, GameObject, Collider>(gameObject, "OnHealthDamage", OnDamage);
    }

    /// <summary>
    /// The object has taken damage.
    /// </summary>
    /// <param name="amount">The amount of damage taken.</param>
    /// <param name="position">The position of the damage.</param>
    /// <param name="force">The amount of force applied to the object while taking the damage.</param>
    /// <param name="attacker">The GameObject that did the damage.</param>
    /// <param name="hitCollider">The Collider that was hit.</param>
    private void OnDamage(float amount, Vector3 position, Vector3 force, GameObject attacker, Collider hitCollider)
    {
        BleedBehavior.BloodAmount += Mathf.Clamp01(damageBloodAmount * amount);

        Debug.Log("Object took " + amount + " damage at position " + position + " with force " + force + " by attacker " + attacker + ". The collider " + hitCollider + " was hit.");
        

        //BleedBehavior.minBloodAmount = maxBloodIndication * amount;
    }

}
 
Can You please tell me how to spawn player health flash using Real Blood Asset? On camera lens of the first person player. I am using Nolan character.

So far in my understanding
under the CANVAS >Monitors> Health Flash.

But there is only image component and health flash component attached to the HealthFlash game object.
 

Andrew

Well-known member
I'm not familiar with that asset - if it's just a pack of textures then you can just use the HealthFlashMonitor component exactly the same as the Health Flash gameobject in the demo scene. (You should be able to duplicate that gameobject and use multiple different ones if needed.)
 
Top