Hello, just spent some time today getting UCC and Real Blood to work together and I thought I'd share the results.
To get the two to work together do the following:
1) Create a C# script named RealBloodShootableObject.cs and paste the following code into it:
2) Open one of the UCC shooter demo scenes and add DecalsProjector.cs from Real Blood to Nolan.
3) Add one of the prefabs ("doll_for_shooting" for example) from Knife->RealBlood->Prefabs->Demo folder to the demo scene.
4) Copy RealBloodShootableObject.cs onto the prefab children objects that have colliders and set LayerMask to TransparentFX or Everything.
5) Select Nolan's AssaultRifle and make sure that the Impact Layers layer mask includes TransparentFX.
6) Hit play and hopefully it should work and this proved helpful.
Real Blood on UAS
To get the two to work together do the following:
1) Create a C# script named RealBloodShootableObject.cs and paste the following code into it:
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Knife.RealBlood;
using Opsive.Shared.Events;
public class RealBloodShootableObject : MonoBehaviour
{
public LayerMask ShotMask;
public void Awake()
{
EventHandler.RegisterEvent<float, Vector3, Vector3, GameObject, object, Collider>(gameObject, "OnObjectImpact", OnImpact);
}
void OnImpact(float amount, Vector3 position, Vector3 forceDirection, GameObject attacker, object attackerObject, Collider hitCollider)
{
// Debug.Log(name + " impacted by " + attacker + " on collider " + hitCollider + "." + amount);
var hittable = hitCollider.GetComponent<IHittable>();
Ray r = new Ray(Camera.main.transform.position, Camera.main.transform.forward);
RaycastHit hitInfo;
if (Physics.Raycast(r, out hitInfo, 1000, ShotMask, QueryTriggerInteraction.Ignore))
if (hittable != null)
{
DamageData[] damage = new DamageData[1]
{
new DamageData()
{
amount = amount,
direction = r.direction,
normal = hitInfo.normal,
point = hitInfo.point
}
};
hittable.TakeDamage(damage);
}
DebugShot(r, hitInfo);
}
protected void DebugShot(Ray r, RaycastHit hitInfo)
{
if (hitInfo.collider != null)
{
Debug.DrawLine(r.origin, hitInfo.point, Color.green, 3f);
}
else
{
Debug.DrawLine(r.origin, r.GetPoint(1000), Color.red, 3f);
}
}
public Vector3 GetLookDirection()
{
return Camera.main.transform.forward;
}
public void OnDestroy()
{
EventHandler.UnregisterEvent<float, Vector3, Vector3, GameObject, object, Collider>(gameObject, "OnObjectImpact", OnImpact);
}
}
2) Open one of the UCC shooter demo scenes and add DecalsProjector.cs from Real Blood to Nolan.
3) Add one of the prefabs ("doll_for_shooting" for example) from Knife->RealBlood->Prefabs->Demo folder to the demo scene.
4) Copy RealBloodShootableObject.cs onto the prefab children objects that have colliders and set LayerMask to TransparentFX or Everything.
5) Select Nolan's AssaultRifle and make sure that the Impact Layers layer mask includes TransparentFX.
6) Hit play and hopefully it should work and this proved helpful.
Real Blood on UAS