I made each tile turn black till it reach and it didn't print "done

{
    private int tilly = 64;
    int counter = 0;

    void OnCollisionEnter(Collision collision)
    {
        if(collision.gameObject.tag == "Player")
        {
            gameObject.GetComponent<Renderer>().material.color = Color.black;
            counter = counter + 1;
            print(counter);

            if(counter == tilly)
            {
                print("done");
            }
        }
    }

and furthermore, what’s funny that it keep duplicating whenever i roll over the “already” black tiles

Print out count each time. What is it getting to?

The Problem is that Counter is never == tilly …

as you can see, your Counter at the Value “1” gets called 64 Times but its value is not 64 so it wont procceed

To expand on this: almost certainly you have this script on the wrong “end” of the collision.

If you have one player and 64 tiles, and this script is on the tile, then you have 64 different “Counter” variables. Each one gets increased to one, but none will ever reach 64.

You should put this code on the player instead (and of course change the tag check to check for tiles rather than checking for the player).

1 Like

then what should i do to make it like that black tiles alrdy been called? pls help im stuck. and mission compelte when all 64 tiles turn black

then what should i do to make it like that black tiles alrdy been called? pls help im stuck. and mission compelte when all 64 tiles turn black

I’m now put that script on the player alrdy. its seems better but seems to me the problem still persist