- Home /
Raycast show ParticleSystem through an Array
I have a character (an Orc) composed by:
Model
ParticleSystem1
particleSystem2
TextMesh
And i need to show the second particle system on mouse over with Raycast with this code:
public Ray ray;
public RaycastHit hit;
void Update ()
{
ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, out hit))
{
if (hit.collider.tag == "Enemy")
{
Component[] particles = hit.collider.GetComponentsInChildren <ParticleSystem> ();
foreach (ParticleSystem particle in particles)
{
if (particle.name == "SelectFx")
particle.Play ();
}
print (hit.collider.tag);
}
}
}
But it shows when the mouse exits from the Orc and disappear on mouse over the object... I've noticed this behaviour even in other functions like that (for example when i play a sound, it plays when i stop the action instead of when i start it). Any suggestion? What I do wrong?
Comment