KROYSDOCS
HomeWhat's newv0.1.0

WaitForSeconds

Continues the coroutine after a number of seconds of game time, counted down with each frame's delta time (so never sooner than the next frame).

Kindclass
NamespaceKroys.EngineScripting
Members1
SourceCoroutine.cs
EXAMPLE

In a script

A complete script that uses WaitForSeconds; copy it into your scripts project.

Coroutines.cs
public sealed class Respawner : EntityScript
{
    public float Delay = 3.0f;

    public void OnDied() => StartCoroutine(RespawnLater());

    private IEnumerator RespawnLater()
    {
        Debug.Log($"Respawning in {Delay} s");
        yield return new WaitForSeconds(Delay);   // game time, counted in frame updates
        Transform transform = Transform;
        transform.Position = new Vector3(0.0f, 1.0f, 0.0f);
        Debug.Log("Respawned");
    }
}
REFERENCE

Members

Constructors
#public WaitForSeconds(float seconds)
Creates a wait of the given length.
seconds
Seconds of game time to wait. Zero or less continues next frame.
constructor
Signatures
public WaitForSeconds(float seconds)

KroysEngine 0.1.0 documentation, built from the engine repository by Tools/BuildDocsSite.py.