- Home /
Question by
$$anonymous$$ · Mar 13, 2018 at 11:24 PM ·
c#unity 5
How can I activate my particules system when it touch an other box collider,How can I activate my particule system when it touch an other box collider?
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class BulletController : MonoBehaviour {
public float speed;
public float lifeTime;
public int damageDoing;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Translate (Vector3.forward * speed * Time.deltaTime);
lifeTime -= Time.deltaTime;
if (lifeTime <= 0) {
Destroy (gameObject);
}
}
void OnCollisionEnter (Collision other) {
if (other.gameObject.tag == "Enemies") {
other.gameObject.GetComponent<EnemiesHealtManager> ().HurtEnemies (damageDoing);
Destroy (gameObject);
}
}
}
Comment
Answer by tormentoarmagedoom · Mar 14, 2018 at 09:50 AM
Good day.
You can instantiate a particle system as a GameObject when OnTriggerEnter, and destroy it OnTriggerExit.
Your answer
![](https://koobas.hobune.stream/wayback/20220612154536im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Must I attach every script to a gameobject in order to work ? 2 Answers
Most efficient way to remove a null object from a dictionary 3 Answers
A real head-scratcher 0 Answers