ok, so i’ve been trying to convert a javascript file to c#… believe i have it mostly done, only one error now, of a type that i haven’t run accross yet… any help, the error in paticular is coming from line 103 :
error CS1624: The body of GnomeAmmoScript.SamplePoints(UnityEngine.Transform)' cannot be an iterator block because
void’ is not an iterator interface type
line 103 : void SamplePoints ( Transform thisTransform ){
?
using UnityEngine;
using System.Collections;
public class GnomeAmmoScript : MonoBehaviour {
private float stationaryTime;
public bool bHasBeenShot;
public bool bHasShouted;
public AudioClip boing;
public AudioClip yipee;
public AudioClip woohoo;
public int AudioFile;
public int BounceAudioFile;
public AudioClip[] BounceAudioList;
public AudioClip[] AudioList;
private AudioSource audioSource;
public bool destroyed = false;
// trajectory path variables
public Material lineMaterial;
public int maxPoints = 500;
public bool continuousUpdate = true;
public GameObject ballPrefab;
public VectorLine pathLine;
public int pathIndex = 0;
public Vector3[] pathPoints;
public bool running = true;
// Use this for initialization
void Start () {
pathPoints = new Vector3[maxPoints];
pathLine = new VectorLine("Path", pathPoints, lineMaterial, 12.0, LineType.Continuous);
SamplePoints (ballPrefab.transform);
bHasBeenShot = false;
bHasShouted = false;
audioSource = GetComponent<AudioSource>();
}
void OnCollisionEnter(Collision collision) {
audioSource.Stop();
BounceAudioFile = Random.Range(0,BounceAudioList.Length);
audio.clip = BounceAudioList[BounceAudioFile];
audio.Play ();
//audioSource.clip = boing;
//audioSource.Play();
}
// Update is called once per frame
void Update () {
if (bHasBeenShot !bHasShouted)
{
bHasShouted = true;
//audioSource.Stop();
AudioFile = Random.Range(0,AudioList.Length);
audio.clip = AudioList[AudioFile];
audio.Play();
//audioSource.clip = (Random.value > 0.5f) ? yipee : woohoo;
//audioSource.Play();
}
if (bHasBeenShot rigidbody.velocity.magnitude < 0.2f)
{
// Don't update the stationary time
if ((Time.time-stationaryTime) > 1.0f)
{
Destroy(gameObject);
destroyed = true;
}
}
else
{
stationaryTime = Time.time;
}
}
void SamplePoints ( Transform thisTransform ){
running= true;
while (running) {
pathPoints[pathIndex] = thisTransform.position;
if (++pathIndex == maxPoints) {
running = false;
}
yield return new WaitForSeconds(.05);
if (continuousUpdate) {
DrawPath();
}
if (destroyed == true)
{
Vector.DestroyLine(pathLine);
}
}
}
void DrawPath (){
if (pathIndex < 2) return;
pathLine.maxDrawIndex = pathIndex-1;
Vector.DrawLine (pathLine);
Vector.SetTextureScale (pathLine, 1.0f);
}
}