what is wrong in this script

hello,

i am not able to enter to the “if” block in the update function. No matter what i do, i couldnt fix it, can anyone please help me?

public class cankaybetme : MonoBehaviour {





    public bool suresaymayibaslat;
void Update ()

    {


        Debug.Log("suresaymayibaslat2:" +suresaymayibaslat);

...............
...............
...............
..............
.............
void OnTriggerEnter2D(Collider2D col)


    {


        if (col.gameObject.name == "grafik")
   
        {

.....................
.......................
....................
.................
       
            suresaymayibaslat=true;

            Debug.Log ("suresaymayibaslat:" +suresaymayibaslat);

   

        }

which debug.log lines do you see in the output?

hi,
i am seeing this debug.log

I’m not sure which object this is attached to - are you sure you aren’t destroying it? You set carptimi to true, then immediately seek out this script on the game objects “altcollider” and “ustcollider” and destroy them.

Zaladur might be right… try putting a debug.log at the begining of the update function.

hi,
Under the ontriggerenter2d function, despite of ı make the the “true” the variable of “suresaymayıbaslat”, in the update function, the value of the variable is always returning the “false” value, can u please help me

public class cankaybetme : MonoBehaviour {





    public bool suresaymayibaslat;
void Update ()

    {


        Debug.Log("suresaymayibaslat2:" +suresaymayibaslat);

...............
...............
...............
..............
.............
void OnTriggerEnter2D(Collider2D col)


    {


        if (col.gameObject.name == "grafik")
   
        {

.....................
.......................
....................
.................
       
            suresaymayibaslat=true;

            Debug.Log ("suresaymayibaslat:" +suresaymayibaslat);

   

        }

i still couldnt solve the problem :frowning: help me please?

See that number after the false? 620? I’m willing to bet that when the trigger is entered and the variable is set to true, that number stops rising. You can verify by clearing the console after it reads true.

The problem is that, after setting the variable to true, you then DESTROY the script. Update is no longer run. That portion of code is never reached.

thank you! i solved the problem!