Quantcast
Viewing latest article 17
Browse Latest Browse All 50

yield return new WaitForSeconds is taking to long?

I'm using AngryAnt's behave and Starting my behave tree like this:

IEnumerator Start ()
{
    OriginalMaxSpeed = GetComponent<AutonomousVehicle>().MaxSpeed;
    m_Tree = BLNewBehaveLibrary0.InstantiateTree(
        BLNewBehaveLibrary0.TreeType.TrafficCollection_CivilianTrafficTree,
        this);

    while (Application.isPlaying && m_Tree != null)
    {
        yield return new WaitForSeconds(1.0f / m_Tree.Frequency);
        AIUpdate();
    }
}

However using the Unity built-in profiler it's showing this is taking 14ms each time and this script is attached to to every vehicle since it's the behavior for vehicles.

Am I doing something wrong? Should WaitForSeconds be taking this long? What is an alternative to using WaitForSeconds()?


Viewing latest article 17
Browse Latest Browse All 50

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>