x


Huh! InvokeRepeating fires twice w/ zero ?

Has anyone noticed this?

If you use InvokeRepeating, with the first argument exactly zero ..

it seems to fire TWICE on that first firing. Strange!

Does everyone else know this other than me? Is this a well-known bug?

Thanks...

more ▼

asked Jun 20 '12 at 04:07 PM

Fattie gravatar image

Fattie
19.1k 57 87 148

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Huh, I'm getting the same results with this very simple test script:

using UnityEngine;
using System.Collections;

public class InvokeTest : MonoBehaviour 
{
    void Start () 
    {
       InvokeRepeating("Tick", 0f, 1f);
    }

    void Tick()
    {
       Debug.Log(Time.timeSinceLevelLoad);
    }
}

"0" logs twice, with further logs coming in once every second.

This is the first I've heard of this issue, but I found this thread from last December, which includes a suggestion to use a very small number like 0.001 instead of 0.

more ▼

answered Jun 20 '12 at 04:41 PM

rutter gravatar image

rutter
5.2k 2 11

Have you tried with 0.0f to see what it does?

Jun 20 '12 at 06:50 PM fafase

RIght, rutter ! it's bizarre huh. Thank goodness it's not just me going crazy.

(I was like "WTF, two spaceships ?!")

What a strange bug. It's almost unbelievable they haven't fixed that since last year!

Jun 20 '12 at 07:50 PM Fattie

@Fattie - you should use coroutines ;)

Jun 20 '12 at 07:52 PM whydoidoit

Mike --- L O L !!!!!!!!!!!!

Jun 22 '12 at 12:06 PM Fattie
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x50

asked: Jun 20 '12 at 04:07 PM

Seen: 355 times

Last Updated: Jun 22 '12 at 12:06 PM