[1065] Feedback: Add a way to invalidate delayed events
tracked
FairlySadPanda
Events that are delayed are useful, but also tricky to use because they cannot be invalidated if the context of the delay is no longer valid (for example, a game timer that lasts ten seconds, but the game is terminated after five seconds).
The event delay function(s) should return some sort of thin object that can invalidate the delayed event or fire it immediately, or return a reference to the unique delayed event ID so that a function can accept that ID as an argument so it can be invalidated.
Log In
DrakenStark
After a lot of logical puzzling, I finally have a solution that doesn't rely on counting deltaTime. See the other post I made here.
Special thanks to ArtySilvers in helping me get over a logical wall.
DrakenStark
Thought of a workaround for how to "cancel" with CustomEventDelayedSeconds.
- To allow only the initial call, use a boolean to block additional calls until the function is called. Reset the boolean in your target function.
- To allow only the most recent call, use an integer to count the number of calls made. Have your target function subtract one from that integer and only run your intended code if the count is equal to one.
- To cancel midway into any number of calls, create two integers. One to count the number of calls made. Have your target function separately subtract one from each integer if it is greater than 0. Only run your intended code if the counting integer is greater than the second integer. Upon canceling, set the second integer to be equal to whatever the current counting integer is.
Tupper - VRChat Head of Community
Excellent idea, but this is out of scope for this release. Moving this item to Udon Feedback.
DrakenStark
Tupper - VRChat Head of Community: I now have a scripted UdonSharp workaround for this item (without any deltaTime accumulation) if it may be of use. My own toggle script on the VRCPrefabs SDK3 database has successfully implemented it if anyone would like to gander.
Tupper - VRChat Head of Community
marked this post as
tracked