Bullet holes and blood efect

hi guys

I have a problem with raycast script
I’m trying to make hit effect.

var holes : GameObject;
var Blood : GameObject;

function shoot (){

GameObject.Find("9mm").animation.Play("gunShoot");
var Hit : RaycastHit;

var DirectionRay = transform.TransformDirection(Vector3.forward);
Debug.DrawRay(transform.position , DirectionRay * distance , Color.blue);
if(Physics.Raycast(transform.position , DirectionRay , Hit ,distance)) {



if(Hit.collider){
Hit.transform.SendMessage("Applydemage", demage , SendMessageOptions.DontRequireReceiver);

.

if(Hit.transform.name == "wall"){
Instantiate(holes,Hit.point, Quaternion.FromToRotation(Vector3.up, Hit.normal));


if(Hit.transform.name == "enemy"){
Instantiate(Blood,Hit.point, Quaternion.FromToRotation(Vector3.up, Hit.normal));

effect problem is bullet holes and blood do not work both
but only one. the one that is written in in the script the above

Thank you for your observations
Please forgive the bad language

From what I see in your code, before you apply the blood or the bullet holes effect. You are checking the transform’s name for both of them. I think it’s impossible to apply those two effects at the same time for the same object since it can not have two names. You said that the bullet holes only are working, that’s because your transform’s name is “wall”.

It’s not the same object,
I’m trying to make effects for different objects …

script works as follows
when the shoot into the wall effect to show up.
when the to shoot the enemy, nothing happens.

Here’s the problem: You are using an If statement to check if the object name is wall then apply the bullet holes effect and in the same If statement you put another condition checking the object’s name is enemy and that’s impossible, that’s why the blood effect does not work for you. Try to separate them like this:

if(Hit.transform.name == "wall"){

Instantiate(holes,Hit.point, Quaternion.FromToRotation(Vector3.up, Hit.normal));

}  //Close this If statement.

//Start another If statement.
if(Hit.transform.name == "enemy")
{

Instantiate(Blood,Hit.point, Quaternion.FromToRotation(Vector3.up, Hit.normal));

} //Close it.

This way it will check if the object’s name is a wall or an enemy and will apply the bullet holes or blood effect.

SoumiDelRio

Thank you very much for your help
now works great