Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlireza Lorzadeh
1,403 PointsInstantiate collision particle
I'm playing around and doing some practice with unity in 2d environment. I have two objects colliding to one another (in 2d space) and I would like to add a particle effect to it. Here is the code that I'm running:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ColisionGreen : MonoBehaviour { [SerializeField] private GameObject GreenParticle; void OnCollisionEnter (Collision col) { if(col.gameObject.name == "Green") { Instantiate (GreenParticle, transform.position,Quaternion.identity); Destroy(gameObject);
}
}
}
Script runs but it does not show the particle effect.
Thanks,
Ali
Alireza Lorzadeh
1,403 PointsAlireza Lorzadeh
1,403 Pointspublic class ColisionGreen : MonoBehaviour{
}
Here is the code again.