Beispiel #1
0
    public static void Door_UpdateAction(InstalledObject installedObject, float deltaTime)
    {
        // If the door isOpening is 'true' open the door a little bit more
        if (installedObject.GetParameter("isOpening") >= 1)
        {
            installedObject.ChangeParameter("OpenValue", (deltaTime * 4));

            // If door is fully opened, close it again (right away)
            if (installedObject.GetParameter("OpenValue") >= 1)
            {
                installedObject.SetParameter("isOpening", 0);
            }
        }
        // Close door again
        else
        {
            installedObject.ChangeParameter("OpenValue", (deltaTime * -4));
        }

        // Clamp value between 0 & 1
        installedObject.SetParameter("OpenValue", Mathf.Clamp01(installedObject.GetParameter("OpenValue")));

        // Call the callback if there is any
        if (installedObject.cb_OnChanged != null)
        {
            installedObject.cb_OnChanged(installedObject);
        }
    }