x


On Which Particle Collision

Hi,

I setup a ParticlePrefab that instantiates for the player when I press a certain key on the keyboard. When the particles collide with an object that is a trigger, our OnParticleCollision(GameObject other) function will know about that collision. Which is great, but not exactly what I need to happen.

Once that the first particle collides with the object that is a trigger, I need to kill a fixed number of particles (like 8 or 9) after that first particle, stop the instantiation for n seconds, and then repeat the instantiation.

A possible solution is may be storing a fixed amount of particles in an array. Here is some code:


using UnityEngine;
using System;

public class Player : MonoBehaviour 
{   
    public GameObject ParticlePrefab;
    public static GameObject instantiated;
    void Update () 
    {
         // Move Player Code            
    }
    void OnTriggerStay(Collider other)
    {       
        if (Input.GetKeyDown("h"))  
        {
            instantiated = (GameObject) Instantiate(ParticlePrefab, transform.position, Quaternion.identity);
        }
    }
          void OnParticleCollision(GameObject other)
          {
              Debug.Log("Particle Collided");
          }
}
more ▼

asked May 27 '10 at 06:18 PM

lampshade gravatar image

lampshade
391 84 92 110

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2584
x335
x51

asked: May 27 '10 at 06:18 PM

Seen: 1357 times

Last Updated: May 28 '10 at 03:21 AM