Tutorial - Time – Ylands
No edit summary |
Lou Montana (talk | contribs) m (Text replacement - "Category: Tutorial" to "Category: Ylands Tutorial") |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
Sometimes you need something to happen with a delay or to keep happening continuously in a loop. First option is to use the '''Delay''' instruction, but you can as well use '''Time Game Logic'''. | Sometimes you need something to happen with a delay or to keep happening continuously in a loop. First option is to use the '''Delay''' instruction, but you can as well use '''Time Game Logic'''. | ||
Line 10: | Line 4: | ||
This object allows you to perform something after a give amount of time (you can specify whether real time or game time). Because you can set how many times the waiting and event execution should repeat you can make a loop (an infinite one, if you specify -1) as number of repeats. | This object allows you to perform something after a give amount of time (you can specify whether real time or game time). Because you can set how many times the waiting and event execution should repeat you can make a loop (an infinite one, if you specify -1) as number of repeats. | ||
Another important thing to know is that the Time Game Logic doesn’t run when it | Another important thing to know is that the Time Game Logic doesn’t run when it is disabled. So when you want something to happen five seconds after,say , entering a Trigger Zone, you create Time Game Logic, set the time to 5s and disable it. Then you enable it when the player enters the trigger zone… and that’s it. | ||
Line 30: | Line 24: | ||
'''Note:''' | '''Note:''' | ||
When you set something to trigger '''On game start''' or right away by having the Time Game Logic enabled with no delay set, please bear in mind that game start doesn’t equal the moment when you see your scene after loading. The game starts in the background and objects are being initialized | When you set something to trigger '''On game start''' or right away by having the Time Game Logic enabled with no delay set, please bear in mind that game start doesn’t equal the moment when you see your scene after loading. The game starts in the background and objects are being initialized first before the camera is enabled and this can take anything from few seconds to several dozens of seconds (when starting a dedicated server session). | ||
Line 36: | Line 30: | ||
One of the worst things you can do when it comes to game performance is to perform operations within a looped Time Game Logic with a very short wait time. The shorter the time between each execute and more heavy the script you perform, the more significant impact on game's performance it has. If you are not sure whether your game runs slowly because of your scripting, be sure to check the performance profiler. | One of the worst things you can do when it comes to game performance is to perform operations within a looped Time Game Logic with a very short wait time. The shorter the time between each execute and more heavy the script you perform, the more significant impact on game's performance it has. If you are not sure whether your game runs slowly because of your scripting, be sure to check the performance profiler. | ||
---- | |||
{{Navbox/Ylands}} | |||
{{DEFAULTSORT:{{#sub:{{PAGENAME}}|18}}}} | |||
[[Category: Ylands Tutorial]] |
Latest revision as of 16:44, 16 November 2022
Sometimes you need something to happen with a delay or to keep happening continuously in a loop. First option is to use the Delay instruction, but you can as well use Time Game Logic.
This object allows you to perform something after a give amount of time (you can specify whether real time or game time). Because you can set how many times the waiting and event execution should repeat you can make a loop (an infinite one, if you specify -1) as number of repeats.
Another important thing to know is that the Time Game Logic doesn’t run when it is disabled. So when you want something to happen five seconds after,say , entering a Trigger Zone, you create Time Game Logic, set the time to 5s and disable it. Then you enable it when the player enters the trigger zone… and that’s it.
The Lamps
Here you can see an infinite loop that always waits few seconds, then executes On Trigger (which makes the lamp go on or off) and then waits again.
The Countdown
There are two Time Game Logic objects located in the corner of the wooden railing. One is set to execute in 10 seconds. Because it is enabled by default it will execute 10 seconds after that game starts. Then it enables the second Time Game Logic, which will perform five “ticks”, each 0.5s apart. On every execute we show a countdown variable's current value and reduce it by 1.
The Equipment
When a player steps in front of the armor we use Delay script tile to gradually change players equipment.
Note:
When you set something to trigger On game start or right away by having the Time Game Logic enabled with no delay set, please bear in mind that game start doesn’t equal the moment when you see your scene after loading. The game starts in the background and objects are being initialized first before the camera is enabled and this can take anything from few seconds to several dozens of seconds (when starting a dedicated server session).
Note:
One of the worst things you can do when it comes to game performance is to perform operations within a looped Time Game Logic with a very short wait time. The shorter the time between each execute and more heavy the script you perform, the more significant impact on game's performance it has. If you are not sure whether your game runs slowly because of your scripting, be sure to check the performance profiler.