- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
$$anonymous$$ · Mar 13, 2018 at 11:25 PM ·
c#unity 5
How can I activate my particules 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 DBoxVR · Mar 14, 2018 at 02:02 AM
Add this variable at the top:
public GameObject myParticles;
Put this ahead of the Destroy() in OnCollisionEnter
particles = Instantiate (myParticles, transform.location, transform.rotation);
Then drag a prefab of your particle system into the script.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Only Allow One Click on GameObject? 2 Answers
Changing one script through another? 2 Answers
RPGStatSystem tutorial problem with clases visibility? 1 Answer