Error-The body of “Practice.MoveObject(UnityEngine.Transform, UnityEngine.Vector3, UnityEngine.Vector3, float)” cannot be an iterator block because void is not an iterator interface type
using UnityEngine;
using System.Collections;
public class Practice : MonoBehaviour {
public Vector3 pointB;
public Vector3 pointA;
public float rate = 0.0f;
public float y = 0.0f;
public float z =0.0f;
public bool show = false;
public void Start()
{
pointA= transform.position;
while(!show)
{
yield return new MoveObject(transform, pointA, pointB, (float)3.0);
yield return new MoveObject(transform, pointB, pointA, (float)3.0);
}
}
void Update ()
{
}
public void MoveObject(Transform thistransform,Vector3 startpos,Vector3 endpos,float x)
{
rate = (float)1.0/x;
while(z<1.0)
{
z+= Time.deltaTime*rate;
thistransform.position = Vector3.Lerp(startpos, endpos,z);
yield return 0 ;
}
}
}