- Home /
How do I have blood particles come out of a spot that got hit
I have a player and some enemies. When I collide with enemy_bullet I want blood to come out where he is hit. How would I do this?
Comment
Answer by Griffo · Feb 23, 2013 at 01:30 PM
Try this -
#pragma strict
var bloodPrefab : GameObject;
private var hit : RaycastHit;
function Start () {
}
function Update () {
var ray : Ray = Camera.main.ViewportPointToRay (Vector3(0.5,0.5,0));
if (Physics.Raycast (ray, hit, 1000)){
transform.Instantiate(bloodPrefab, hit.point + transform.forward * 0.5, Quaternion.identity);
}
}
Wiki
Answer by DryTear · Feb 26, 2013 at 12:25 AM
var bloodPrefab : GameObject;
function OnCollisionEnter(col : Collision)
{
if(col.gameObject.tag == "Bullet")
{
Instantiate(bloodPrefab, gameObject.transform, gameObject.rotation, 0);
//Do Stuff
}
}
}
Attach this onto the player, and then after the Instantiate part do your "kill the player" thing
Bullet has to have a tag "Bullet"
Your answer
Follow this Question
Related Questions
Slow Particle Down Inside Collider 1 Answer
Make particles stay on ground 0 Answers
Unity Particle System collision detection problem 1 Answer
Show GUI texture on collison 1 Answer