|
Post by xianno on Apr 5, 2020 13:05:21 GMT
Hi!
I'm actually using EventWithDelay to SetActive false, or StopParticles but it's not working as I want! Let's take an example.
My character is using a spell that allows him to walk on water for 30 secs. I'm using a script that makes him walks on "water tag" for 30 secs, and then need to disable it. That's where I use EventWithDelay. When activating the first script, I SetActive true an empty with the EventWithDelay and checked "on Start". I SetActive false this same EventWithDelay at the end of the countdown.
But when I reactivate my spell, it won't cancel after 30 secs. If it's a particle it's not hard to set it to stops automatically, even if some issues can appear, but for scripts or bonuses like speed, fly, walk on water etc... I have no clue. Because if you destroy the script, empty, object after 30 secs, it's destroyed, and won't be SetActive true or anything else anymore...
Do I need to instantiate an empty with my script, then destroy it and so on? Won't it create issues if the player spams this abilitie (like overspawn)
I hope I'm clear enough for you to understand my problem :')... Thanks in advance!
|
|
|
Post by Invector on Apr 6, 2020 18:00:50 GMT
By checking the 'TriggerOnStart' option it will trigger on start, which is once you loaded the scene... if you want to trigger everytime your script is enabled you need to change the Start() method to Enable()
|
|
|
Post by xianno on Apr 6, 2020 22:52:45 GMT
By checking the 'TriggerOnStart' option it will trigger on start, which is once you loaded the scene... if you want to trigger everytime your script is enabled you need to change the Start() method to Enable() Fine! That is working as I want, thank you! For info, if you check on Start and the GameObject isn't active when the scene starts, activating the object will make it act like on Start! That's why I was doing it wrong I think!
|
|