Hello, I’m trying to convert this sample JS code from the ParticleEmitter.particles documentation into C#:
// Attach this script to an existing particle system.
function LateUpdate () {
// extract the particles
var particles = particleEmitter.particles;
for (var i=0; i<particles.Length; i++) {
// Move the particles up and down on a sinus curve
var yPosition = Mathf.Sin (Time.time) * Time.deltaTime;
particles[i].position += Vector3 (0, yPosition, 0);
// make the particles red
particles[i].color = Color.red;
// modify the size on a sinus curve
particles[i].size = Mathf.Sin (Time.time) * 0.2;
}
// copy them back to the particle system
particleEmitter.particles = particles;
}
Starting with the first line in the block:
ParticleEmitter[] particles = particleEmitter.particles;
I’m getting stuck with the following error:
error CS0029: Cannot implicitly convert type UnityEngine.ParticleEmitter.particles' to
UnityEngine.ParticleEmitter[ ]’
I’ve only been using C# for a few days; would someone mind pointing me in the right direction? I just want to assign a reference to the particles array to a local variable. (Yes, I’ve searched the forums and google… :? )
Thanks,
John