Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

 for (int c = 0; c < Distance.Length; c++)

        {

            Distance[c] = 0;

        }

        BillyRangeXRight = BillyObject.transform.position.x + 0.8f;

        BillyRangeXLeft = BillyObject.transform.position.x - 0.8f;

        c = 0;

        for (int i = 0; i < BulletsObject.transform.childCount; i++)

        {

            BulletsObjects[i] = BulletsObject.transform.GetChild(i).gameObject;

           if( BulletsObjects[i].transform.position.x<BillyRangeXRight && BulletsObjects[i].transform.position.x > BillyRangeXLeft)

            {

                if(BulletsObjects[i].transform.position.y< BillyObject.transform.position.y)

                {

                    IstanceDistance = BillyObject.transform.position.y - BulletsObjects[i].transform.position.y;

                    if (IstanceDistance < 7)

                    {

                        Distance[c] = IstanceDistance;

                        DistanceX[c] = BulletsObjects[i].transform.position.x;

                        c++;

                    }

                }

            }

        }

        float min = Distance[0];

        float DistMinCount = 1;

        float length = Distance.Length;

        float PercentageTextInt=99.9f;

        if (min != 0)

        {

            for (int c = 0; c < Distance.Length; c++)

            {

                if (Distance[c] == min)

                {

                    DistMinCount = DistMinCount + 1;

                }

                if (Distance[c] < min && Distance[c] != 0)

                {

                    min = Distance[c];

                    DistX = Mathf.Abs(BillyObject.transform.position.x-DistanceX[c]);

                }

                if (Distance[c] == 0)

                {

                    length--;

                }

            }

            float minClamp = Remap(min, 0, 7, 0, 1);

            float LengthClamp = Remap(length, 1, 20, 0, 1);

            float DistMinCountClamp = Remap(DistMinCount, 1, 10, 0, 1);

            float DistXClamp = Remap(DistX, 0, 0.7f, 0, 1);

            PercentageTextInt = (1f - (0.6f * (1f - minClamp) + (0.2f * DistMinCountClamp) + (0.1f * LengthClamp) + (0.1f*(1 - DistXClamp)))) * 100f;

        }
This is the part of the code where i take the parameter and calculate where remap is this function :


    float Remap(float value, float from1, float to1, float from2, float to2)

    {

            return (value - from1) / (to1 - from1) * (to2 - from2) + from2;

    }

While the thing on the bottom is kinda strange, it should give you a text and "Billy" (the protagonist) should be  on the platform

(1 edit)

This is in "Update()"