- Home /
Blood decal Instantiate from rigidbody blood object?
Hi , guys thanks for viewing this topic normally I can fix anything , but im having weird issue here now I'm kinda doing decal like bullet holes little flat 3d planes with transparent material attached in this case : my blood texture I made ...
Now I want to create a interesting blood splatter effect like I used too with 2D games ... but im having issue heree....
So when the zombie or baddy gets shot he create's little 3d red cubes with rigidbodies attached to them.... Works great!
Now the new problem is when these cubes collide with floors or walls for that matter they need to instantiate ... splat decals on collision ..... so I wrote a script ... that makes them normilize and rotate based on collision point.... I'm still having major problem though only some of the cubes call my debug out when they hit the floor and no blood splatter I checked the parent of the object... and only 1 splatter was created and this splatter was beneath the floor plane ....
If anyone could help me this would be greatly appreciated it
The CODE SNIPPET HERE ::
//Grab the bloodsplatter prefab of you're choice
var splatterPrefab : Transform;
var splatters : Material[];
function OnCollisionEnter(col: Collision){
var contact: ContactPoint = col.contacts[0]; // get first contact point
// calculate rotation from prefab normal to contact.normal:
var rot = Quaternion.FromToRotation(Vector3.up, contact.normal);
if (col.gameObject.CompareTag("Enemy")){
//Make Dummy statement
}
else{
Debug.Log("Hit a levelpart");
var hole = Instantiate(splatterPrefab, contact.point, rot);
hole.parent = col.transform; // child the hole to the hit object
}
Destroy(gameObject); // destroy blood cube *this works*
}
Hi @12aithe
Hi,$$anonymous$$ake sure that The blood object that you are reffering is prefab and remove all collider,rigidbody from the blood object . $$anonymous$$ake sure you haven't destroyed it Ps.Use Sphere as the object with this script(dont use cube it is not so ideal)
Answer by 12aithe · Feb 24, 2013 at 12:49 AM
EDIT : Sorry about early morning grammar been up all night on blood seams to work for untagged ground but I have other objects marked with different tags ... to play different sounds and have more interaction ....
The Untagged Ground with on collision ... works fine blood comes out grows like puddle... but now for the other ground I just added checks for each tag and modified the Y VALUE on each of the decals..... to go above ground only issue I had " and thanks for the sphere collision that made the rotation of the particles better that topic described what I was trying to do .. but I eventually got there besides sphere collider ....
So it creates decal of other parent's correctly at correct position on vector ,
Now the new weird problem I do not understand is on the blood puddle : attached .js for scaling puddle .... works great on the untagged again ... but for the metal and dirt and other taggs it does not scale the same correctly it's to small to see... or over half the scale of the untagged floor ... nothing different between taggs either so I'm not understanding where the math is wrong here is the scale script ....
var currentTime : float = 0;
private var maxSpread : float = 0.8;
private var thisSpread : float = 0;
var randomSpread : float;
var minRange : float = 0;
function Awake ()
{
transform.rotation.y = Random.rotation.y;
randomSpread = Random.Range(minRange,maxSpread);
}
function Update () {
if ( thisSpread < randomSpread)
{
thisSpread += Time.deltaTime /2;
}
transform.localScale = Vector3(thisSpread/2,thisSpread/2,thisSpread/2);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613093231im_/https://answers.unity.com/themes/thub/images/avi.jpg)