Function to call once a second

Hey! I have read some other answers, and I really don’t know what I’m doing wrong with time.time =/. could anyone help me make this function call once a second?

   void OnePerSecond ()
        {
            if (Time.time == timestamp)
            {
                timestamp = Time.time + 1.0f;
                Debug.Log("a second passed");
    
    
                if (secondsUntilShootBasic < 3)
                {
                    secondsUntilShootBasic = secondsUntilShootBasic + 1;
                }
            }
        }

Hi, your problem is you don’t understand the code processing :
when you write :

    void OnePerSecond ()
         {
             if (Time.time == timestamp)
             {
                 timestamp = Time.time + 1.0f;
                 Debug.Log("a second passed");
                ............
              }
          }

the script execute this : “if actual time is equal to “timestamp” so timestamp equal this time + 1 sec” and herés the problem : it instantly dtop the function so you have to use this code :

    void OnePerSecond ()
         {
             if (Time.time == timestamp)
             {

                 if (secondsUntilShootBasic < 3)
                 {
                     secondsUntilShootBasic = secondsUntilShootBasic + 1;
                 }

                 timestamp = Time.time + 1.0f;
                 Debug.Log("a second passed");

             }
         }

I think you’re void would not be called evrey sec because you have to call this void manualy for it work: you have to write : “OnePerSecond();” in the Update void or call this void as Update:

           void Update ()
         {
             if (Time.time == timestamp)
             {

                 if (secondsUntilShootBasic < 3)
                 {
                     secondsUntilShootBasic = secondsUntilShootBasic + 1;
                 }

                 timestamp = Time.time + 1.0f;
                 Debug.Log("a second passed");

             }
         }

I hope it will work,
tell me if you still have a problem, I would be able to completly resolve it tomorow on my computer because I’m actualy on phone and I’m sorry for my bad english ^^.