How to activate a prefab power ups with different cubes?,Hi guys
Hi guys,
I'll begin by saying what I have done so far. I have made a sphere which is the player, three different powers that are tagged "Pick Up" so the sphere can pick them up, and prefabs for the power ups. What I would like to accomplish is having the sphere activate the fire prefab when it hits the red cube, ice prefab with the ice cube, and water prefab with the blue cube. I currently have my script attached to my sphere and it works for my fire prefab, but I'm little confuse on how to get the other two prefabs to work with their power ups. I'm still pretty new to scripting, but I believe it has something to do with OnTriggerEnter and assigning tags . Any help or an example is greatly appreciated.
using UnityEngine; using System.Collections;
public class UP : MonoBehaviour {
public ParticleSystem Fire;
//public ParticleSystem Ice;
//public ParticleSystem Water;
// Use this for initialization
void Start () {
Fire.GetComponent<ParticleSystem> ().enableEmission = false;
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter()
{
Fire.GetComponent<ParticleSystem>().enableEmission = true;
StartCoroutine(stopFire());
}
IEnumerator stopFire()
{
yield return new WaitForSeconds(9.0f);
Fire.GetComponent<ParticleSystem>().enableEmission = false;
}
}
,
Your answer
Follow this Question
Related Questions
Get a Insantiate particle system follow a GameObject 1 Answer
Particle Systems slowing game down too much. 0 Answers
Enable and disable of prefab components 1 Answer
How do I make this script play a particle sytem from prefab 1 Answer
Can the new ParticleSystem Trigger Module access the particle's collision collider? 0 Answers