Tutorial - Time – Ylands

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - "{{Ylands editor navbox}}" to "{{Navbox/Ylands}}")
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
----
{{Ylands editor navbox}}
{{DEFAULTSORT:{{#sub:{{PAGENAME}}|18}}}}
[[Category: Tutorial]]
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's 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.
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 few seconds before the camera is enabled so when you set something to happen 10s after the game starts, it can happen something like 5s after the camera is enabled.
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: Tutorial]]

Revision as of 07:00, 31 December 2020

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.