I am trying to make something shrink when my player ‘eats’ it. So far I found some javascript code and trans-coded it to c#. I only have 1 error left, the one stated in the title. No matter what I search nothing I have tried fixes it. The line that is giving the error is line 18. Any help is much appreciated.
using UnityEngine;
using System.Collections;
public class food : MonoBehaviour {
void Start () {
}
void Update () {
}
void OnCollisionEnter (Collider other) {
StartCoroutine(LerpScale(2.0f));
}
void LerpScale (float time){
var originalScale = transform.localScale;
var targetScale = originalScale - Vector3(1.0f, 0.0f, 1.0f);
var originalTime = time;
while (time > 0.0f) {
time -= Time.deltaTime;
transform.localScale = Vector3.Lerp(targetScale, originalScale, time / originalTime);
yield return 0;
}
}
}