Time.deltaTime is a float, is there a way to change it into an int?

Hey, im trying to spawn a customer during a certain time but Time.deltaTime is a float, is there a way to change it into an int?

Now i did in the update if hours == 8 and minutes == 30 then spawn a customer but it’ll never spawn a customer because time. delta is a float and it prints out long numbers.

How could I make it into an int?

I did try roundtoint and floortoint but it did not work.

It seems like you’re using time.deltaTime wrong somehow. In this case you increment a variable by it (variable += Time.deltaTime) and then check if it is >= to the time you want, rather than == to. That way the variable keeps track of the time that has passed and whenever it reaches or exceeds the goal time, it does something.

so I did try that,in my update im using a switch case, so I have it as if hours >= 8 and minutes >= 30 itll spawn a customer but it wont spawn a customer at the next time. which is another if block saying hour >= 8 and minutes >= 45 then spawn but it does not spawn there , maybe its how i have my switch statement setup?

Time.deltaTime is in the units of seconds and will report the amount of time since the last Update(). If you want to get an absolute time, you can use Time.time.

Mathf.RoundToInt(), Mathf.FloorToInt(), and Mathf.CeilToInt() are all different ways to convert a float to an int. But I don’t think you want to use these on Time.deltaTime because this will almost always be a value less than 1.0. When you convert it to an int it will be either 0 or 1. If you are trying to keep a timer, then you will probably want to keep the timer as a float otherwise it will not work as intended.

It is not clear how you are trying to convert time into hours and minutes. Please share your code.

public int currentDay = 1;
public Transform spawnPoint;                                                        
public bool  isCustomerEntering = false;
private void Update()
{

   float hour = GetHour();
   float minutes = GetMinutes();
   Debug.Log(hour + " " + minutes);

   switch (currentDay)
   {
       case 1:
           if (!customerSpawned)
           {

               if (hour >= 8f && minutes >= 2f)
               {
                   Debug.Log("Spawned Customer");
                   customerManager.InstantiateCustomer();
                   customerSpawned = true;
               }

               if (hour >= 8f && minutes >= 5f)
                   {
                       
                       Debug.Log("Spawned Customer");
                       customerManager.InstantiateCustomer();
                       customerSpawned = true;
                   }
               }
           
           endOfDay = true;
           break;
   }
}


public float GetHour()
{

   return currentTime * hourInDay / dayDuration;
}

public float GetMinutes()
{
   return (currentTime * hourInDay * minutesInHour / dayDuration) % minutesInHour;
}

IEnumerator clockCounter()
{

   currentTime = startTime;
   endOfDay = false;
   while (clockActive)
   {
       yield return null;

       if (currentTime < workDayLegnth)
       {

           currentTime += Time.deltaTime;

       }
       else
       {
           endOfDay = true;
           break;
       }
   }
   clockActive = false;


}