C
C#15mo ago
Twister

❔ 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
No description
14 Replies
Angius
Angius15mo ago
Well the error is quite clear, isn't it? Also, read the docs of InvokeRepeating: https://docs.unity3d.com/ScriptReference/MonoBehaviour.InvokeRepeating.html
Twister
TwisterOP15mo ago
bro ahaha, Its my first class
Angius
Angius15mo ago
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
Twister
TwisterOP15mo ago
thank you
Angius
Angius15mo ago
So if you want to invoke this method after a second, and then once every 3 seconds, you'd use
InvokeRepeating(nameof(PremierChien), 1f, 3f);
InvokeRepeating(nameof(PremierChien), 1f, 3f);
Note the use of nameof() instead of a magic string "PremierChien"
Twister
TwisterOP15mo ago
I will try thank you for your time And sorry it look stupid
Angius
Angius15mo ago
Everybody had to start somewhere, no worries
Buddy
Buddy15mo ago
I highly recommend not to use InvokeRepeating if you for example want to change the interval at any time during the game.
Twister
TwisterOP15mo ago
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
Buddy
Buddy15mo ago
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.
Twister
TwisterOP15mo ago
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
Buddy
Buddy15mo ago
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 $unitybug
MODiX
MODiX15mo ago
If intellisense is not working for Rider / Visual Studio, follow these steps.
Go into Unity Editor -> Preferences -> External Tools -> Set Visual Studio (or JetBrains Rider) as your preferred editor.
Go into Unity Editor -> Preferences -> External Tools -> Set Visual Studio (or JetBrains Rider) as your preferred editor.
Close the editor and re-open it again by double-clicking a script file.
Accord
Accord15mo ago
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.
Want results from more Discord servers?
Add your server