I want to wait a non-integral amount of seconds( a non whole amount), for example 1.2 secs, I try using the following
using UnityEngine;
using System.Collections;
public class hp : MonoBehaviour {
public MonoBehaviour someJS;
public float health;
void Awake () {
someJS=gameObject.GetComponent("badzom") as MonoBehaviour;
}
IEnumerator MyMethod() {
Destroy(someJS);
animation.Play(“death”);
yield return new WaitForSeconds(1.2);
animation.Stop("death");
Destroy (gameObject);
}
void Update () {
if (health <=0)
{
StartCoroutine(MyMethod());
}
}
}
But Unity throws the following error: Assets/Plugins/hp.cs(17,33): error CS1525: Unexpected symbol (‘, expecting )’, ,‘, ;’, [‘, or =’
Can WaitForSeconds take a decimal amount, or am I doing something else wrong?
EDIT: If i add return new after the yield it gives:
Assets/Plugins/hp.cs(17,46): error CS1502: The best overloaded methodmatch for `UnityEngine.WaitForSeconds.WaitForSeconds(float)'has some invalid arguments
and
Assets/Plugins/hp.cs(17,46): errorCS1503: Argument #1’ cannot convert double’ expression to type `float’
If I wanted to use a float how would I use it with yield?