samedi 19 septembre 2020

Avoid else if too much in fixedupdate

I'm new to unity. How to optimaze too many else if condition like this script? i want to increase fps of my game

   private void FixedUpdate()
    {
        Vector3 desiredPosition = target.position + offset;
        Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed);
        transform.position = smoothedPosition;
        if (PisauScript.nonaktifkamera.manjat == true)
        {
            offset.x = -5;
            offset.y = 14;
            offset.z = 6;
        }
        else if (PisauScript.nonaktifkamera.manjat2 == true)
        {
            offset.x = -14;
            offset.y = 25.5f;
            offset.z = 6;
        }
        else if (PisauScript.nonaktifkamera.manjat4 == true)
        {
            offset.x = -46;
        }
        else if (PisauScript.nonaktifkamera.manjat5 == true)
        {
            offset.x = -62.7f;
            offset.y = 17.5f;
        }
}

Aucun commentaire:

Enregistrer un commentaire