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*
}