How do I Instantiate a blood particle system when I attack an enemy?
How do I Instantiate a blood particle system when I attack an enemy? I want the particle system to be shown when the enemy is hit (AKA blood splatter). I am using the POLYGON - Adventure Pack with the SimpleFX pack.
Edit: I want the particle system to play ON the animation when it plays(anim.Play("damage_2")).
Would be really nice if I could get an answer soon. Since there are like 137 people following this question!!!
Answer by deathpallie_unity · Feb 03, 2021 at 11:00 PM
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Blood : MonoBehaviour
{
public ParticleSystem blood;
public Transform bloodPos;
public Transform activateBloodAt;
void Update()
{
bloodPos.position = activateBloodAt.position;
}
void OnTriggerEnter(Collider collider)
{
if (collider.gameObject.tag == "Weapon")
{
Instantiate(blood);
blood.Play();
}
}
@Bebhinn You can add this to the enemy. Your enemy needs a collider with isTrigger enabled. If you want collisions with your enemy, copy and paste the component and uncheck isTrigger. You should have two colliders now. Your trigger, the one with isTrigger enabled, and your collisions, the one without. You need two because checking isTrigger removes collisions.
Your answer
Follow this Question
Related Questions
setting a particle system to overwrite old particles, to make way for the new? 1 Answer
How can I rapidly trigger the same particle system? 2 Answers
Particle System is behind Background Image (2D) 4 Answers
Little dust particles after player jump hitting ground 2 Answers
Attach particle system to an object 2 Answers