❔ InvokeRepeating, I want to make a +3 repetition
Hello I am new to c#
Its my first time using InvokeRepeating
unity error: Assets\scripts\Click.cs(18,29): error CS1501: No overload for method 'PremierChien' takes 1 arguments
14 Replies
Well the error is quite clear, isn't it?
Also, read the docs of
InvokeRepeating
: https://docs.unity3d.com/ScriptReference/MonoBehaviour.InvokeRepeating.htmlbro ahaha, Its my first class
This method takes the name of the method it has to invoke
And the error is obvious, still. Your
PremierChien()
method takes no parameters, but you're trying to call it with parameter 3
thank you
So if you want to invoke this method after a second, and then once every 3 seconds, you'd use
Note the use of
nameof()
instead of a magic string "PremierChien"
I will try thank you for your time
And sorry it look stupid
Everybody had to start somewhere, no worries
I highly recommend not to use InvokeRepeating if you for example want to change the interval at any time during the game.
Its for a clicker game, like add automatically +3, my teacher told me to use that, i dont understand anything ahah, I am a little bit lost
You can use the Update loop and check if next_tick is lower than current timestamp.
Unfortunately you can't easily change the interval of InvokeRepeating unless you cancel it and then call InvokeRepeating again
If let's say you buy an upgrade which increases the interval of said buff for X seconds, you'd have to cancel the invoke and re-do it, each time the interval is changed.
I think my InokeRepeating is working now, I have another probleme unity tell me that my string need to be in int, but I already put int.Parse but still dont work, i will need to try something else i guess, I realy have to many error, I am losing my mind
Don't have a conditional based on the UI, but have a class which contains the gamestate, such as the number of clicks.
Also note that with
int / Int32
you're limited from -2147483648
to 2147483647
Also this Start method only runs once when the scene has started.
Which means if you at any point during the game get over or equal to 20 clicks, it will never call InvokeRepeating.
Unless you start at 20 or greater.
Note that clickNombre.text must also be a valid integer, otherwise you'll get an exception and the script will never run.
Please do this
$unitybugIf intellisense is not working for Rider / Visual Studio, follow these steps.
Close the editor and re-open it again by double-clicking a script file.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.