- Home /
Targeting particle from particleEmiter
I would like to target one specific emited object and in some external script rotate it in update function. This is part of code:
link = (GameObject) GameObject.Find("emiter_on_scene");
link.particleSystem.Emit(transform.position,transform.rotation,400f,5,color);
this dont work
//link_to_particle_obj = link.particleSystem.Emit(transform.position,transform.rotation,400f,5,color); //this dont work
Is there a way how to get reference to that object?
Comment
Answer by neph_2 · Nov 17, 2013 at 06:47 PM
Solution code put on particle system:
using UnityEngine;
using System.Collections;
public class KontrolaEmitujucichZiarKuKamere : MonoBehaviour {
public Transform linkToPlayer;
public Vector3 smer;
// Use this for initialization
void Start () {
linkToPlayer = GameObject.Find("Player").transform;
}
// Update is called once per frame
void Update () {
//warning optimalizacia toto tu nemusi sa checkovat stale ale napriklad by stacilo kazdu sekundu alebo pod.
ParticleSystem.Particle[] particles = new ParticleSystem.Particle[particleSystem.particleCount];
particleSystem.GetParticles(particles);
smer = linkToPlayer.forward;
for (var i = 0; i < particles.Length; i++) {
particles[i].axisOfRotation = smer;
}
particleSystem.SetParticles(particles,particleSystem.particleCount);
}
}