Hey guys.
I have now created a particle effect and ad it to a prefab. When I start the game the particle effect plays immediately without any collision.
What I’m doing wrong here?
EDIT: I have solved the first problem.
If the collider is destroyed, how I can spawn a new coin-prefab on the same position?
As last, how can I destroy a collider separately? Currently if I’m jumping between the 2 colliders both will destroyed. I would like it that only once per jump destroyed a collider.
I hope you can help me.
Here is the script(on the line 20 for particle effect):
using UnityEngine;
using System.Collections;
public class BlockBreakable : MonoBehaviour {
public float breakableTime = 0.5f;
AudioClip soundBumpBreak;
public string tag = "Player";
public PlayerControllerScript controller;
public Transform particleprefab;
public GameObject coinprefab;
void OnCollisionEnter2D(Collision2D coll)
{
if(coll.gameObject.tag == tag && !controller.grounded)
{
BreakableWait ();
Destroy (this.gameObject, breakableTime);
Instantiate(particleprefab, new Vector3(0, 0, 0), Quaternion.identity);
}
}
IEnumerator BreakableWait ()
{
yield return new WaitForSeconds(breakableTime);
}
void Start ()
{
audio.clip = soundBumpBreak;
audio.Play ();
}
}