Using different reture types then void

So I’m not sure it this is exactly where I should be posting this or not but I need some help with my code.

public bool HandleMovement(bool isWorking)
    {
        if (Input.GetKeyDown("a"))
        {
            transform.Translate(-1f, 0f, 0f);
        }

        if (Input.GetKeyDown("d"))
        {
            transform.Translate(1f, 0f, 0f);
        }

        return true;
    }

I have this code with the return type of bool because I want to turn it off/false when it collide with another gameobject. This is my attempt:

void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.gameObject.tag == "Floor")
        {
            StopCoroutine(coroutine);
            HandleMovement(false);
        }
    }

I’m not the best at coding yet so I’m not too sure how I get it to change to false. Thank you for any and all help!

Hi @technano ,
I want to help you out ~ I think you got confused.
Right now your HandleMovement function will always return true, and it doesn’t use its argument bool isWorking.

I am not sure if I understood what you were after but this might work for you:

 public bool HandleMovement(bool isWorking)
     {
         if(!isWorking) return false;

         if (Input.GetKeyDown("a"))
         {
             transform.Translate(-1f, 0f, 0f);
         }
 
         if (Input.GetKeyDown("d"))
         {
             transform.Translate(1f, 0f, 0f);
         }
 
         return true;
     }