Ошибка CS1955 Невозвратный член 'Particle Emitter.emit' не может использоваться как метод (27) Ошибка CS0029 Невозможно неявно преобразовать тип 'bool' в 'UnityEngine.Particle []' (28) Мой код ошибки.Я работал над этим кодом некоторое время, теперь я сделал его именно так, как мне сказали, и у него продолжают возникать проблемы.Я пытаюсь посмотреть, но не могу найти, что с ним не так.Вот мой сценарий:
using UnityEngine;
using System.Collections;
public class LightningBolt : MonoBehaviour
{
public Transform target;
public int zigs = 100;
public float speed = 1f;
public float scale = 1f;
public Light endLight;
[HideInInspector] public bool emits = false;
Perlin noise;
float oneOverZigs;
private Particle[] particles;
void Start()
{
oneOverZigs = 1f / (float)zigs;
GetComponent<ParticleEmitter>().emit = false;
GetComponent<ParticleEmitter>().emit(zigs);
particles = GetComponent<ParticleEmitter>().emit;
}
void Update ()
{
if(target == null)
return;
if(!emits){
return;
}
endLight.intensity = 1;
if (noise == null)
noise = new Perlin();
float timex = Time.time * speed * 0.1365143f;
float timey = Time.time * speed * 1.21688f;
float timez = Time.time * speed * 2.5564f;
for (int i=0; i < particles.Length; i++)
{
Vector3 position = Vector3.Lerp(transform.position, target.position, oneOverZigs * (float)i);
Vector3 offset = new Vector3(noise.Noise(timex + position.x, timex + position.y, timex + position.z),
noise.Noise(timey + position.x, timey + position.y, timey + position.z),
noise.Noise(timez + position.x, timez + position.y, timez + position.z));
position += (offset * scale * ((float)i * oneOverZigs));
particles[i].position = position;
particles[i].color = Color.white;
particles[i].energy = 1f;
}
GetComponent<ParticleEmitter>().particles = particles;
if (GetComponent<ParticleEmitter>().particleCount >= 2)
{
if (endLight)
endLight.transform.position = particles[particles.Length - 1].position;
}
}
void EmitCharge (bool s) {
emits = s;
endLight.intensity = 0;
}
/* C
*/
void Target (Transform t) {
target = t;
}
}