Search Unity

OnParticleCollision particle position

Discussion in 'Scripting' started by HavocK, Apr 16, 2011.

  1. HavocK

    HavocK

    Joined:
    Apr 16, 2011
    Posts:
    7
    Hey there,

    i've got some trouble. I'd like to know how can i get a particle position in the OnParticleCollision method?

    I saw that there is an array : particleEmitter.particles[] BUT, i don't know how to get the id :/

    I'm using a particle system to create a continuous laser beam. I'd like to instantiate some spaks each time a particle hit a collider. But i can't find a way to spawn those sparks correctly.

    I tried :
    HTML:
    void OnParticleCollision(GameObject other)
    	{
    		if(other.gameObject.layer.ToString() != "Bullets")
    		{
    			//Destroy(other);
    			Instantiate(spark, other.transform.position, transform.rotation);
    		}
    	}
    But this piece of code does spawn the at the center of the object...
    Any clue?

    Regards.

    Edit :
    Ah! NeverMind i've found a way by casting a ray...
     
    Last edited: Apr 16, 2011