Difference between revisions of "An Event in Time"

From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 66: Line 66:
 
  pause for 500 milliseconds
 
  pause for 500 milliseconds
 
  if condition "cond_example" is true
 
  if condition "cond_example" is true
  jump 5 action parts forwards
+
  jump 4 action parts forwards
 
  else
 
  else
display narration text "cond_example is still false"
 
 
  jump to action part #1 (''jump back to first action part'')
 
  jump to action part #1 (''jump back to first action part'')
 
  end if
 
  end if
  display text "hello world" (''this action part should be where jump to 5 action parts forwards goes'')
+
  display text "hello world" (''this action part should be where jump to 4 action parts forwards goes'')
  
  
 +
== Wait Actions ==
 +
 +
Some action parts have an additional option called '''wait''', which enabled will tell the engine to pause the action list until the action or animation has finished. These wait options are optional & can also be very useful for controlling the timing of when certain events should occur.
 +
 +
=== Play Animation and wait ===
 +
 +
This will pause the action list that you execute this action in until the animation finishes, however you do need to be careful not to use this option on animations that are set to infinite loop as the action list will be paused indefinitely due to the animation never ending.
 +
<hr>
 +
== Wait until Sound is Finished ==
 +
 +
This action part will pause the action list that you execute this action in until the linked sound stops playing, however just like '''play animation and wait''' you need to be careful that you don't link to a sound that is looping as the action list will be infinitely due to the sound never ending.
 +
<hr>
 
{{toc}}
 
{{toc}}

Revision as of 19:08, 1 August 2022

On this page you will find a bunch of tips & tricks related to events, loops, & timing methods that you can use to control exactly when specific events &/or state changes (via values/conditions) should occur in your game projects.

Anyway, let's crack on...


Pause (static)

The simplest method for controlling time is to use the pause action part. The pause action part will prevent any action parts created after it from executing until the pause has finished.


Quick note: The pause action part allows you to specify the time in milliseconds, seconds, or minutes; however I highly recommend that you use milliseconds because it allows you to input precise time values.

Anyway, here's an example of the pause action part being used with some other action parts...

if condition "cond_example" is true
pause for 500 milliseconds
change condition "cond_example" to false
end if


Pause (dynamic)

The same action part above can also be used to create dynamic pauses, which can be really useful for making your game projects feel more alive & less like a broken record stuck in a never-ending loop.

To setup dynamic pauses you will need to create a value that you can link to the pause action part. The integer number belonging to values can be modified at any time via action parts or script; however we will only be covering action parts for now to keep things as simple as possible.

Anyway, let's just assume you have created a value somewhere inside of the Visionaire Studio editor & have called it "v_time". Right, let's see an example of what a dynamic pause would look like inside of an action block...

set random value "v_time" between 100 and 3000
pause for "v_time" milliseconds
-- additional action parts go here


Animation Frame Events

Did you know that you can edit animation frames via Anim editframev2.png & assign sounds & actions to each individual animation frame? This is actually a really great method for precision timing based events as they are tied to animation frames instead of the frames per second (fps) that your game is running on each players device. It's much more accurate than using the pause action part.

Vs anim frame actions.png


Jump to Action Part

The jump to action part action part is one of the methods that you can use for creating loops inside of the Visionaire Studio editor without having to resort to scripting. There are 2 ways that you can use the jump to x action part, which are...

Absolute

This is the option you would probably be using most of the time & it's the simplest method as you simply tell the engine to jump to x action part inside of the current action block. For example #1 would be the first action part in the list aka the top of the list.

Here's a quick example of what the action block might look like...

if condition "cond_example" is false (this is where the jump to action part will jump back to)
pause for 500 milliseconds
jump to action part #1
end if
display text "hello world" (if condition "cond_example" is true then this would be executed instead)

Relative

Relative positioning is a bit more complicated as it involves jumping x amount of steps forwards or backwards & is more of a situational option to use.

Here's a little action block example of what it might look like in use...

pause for 500 milliseconds
if condition "cond_example" is true
jump 4 action parts forwards
else
jump to action part #1 (jump back to first action part)
end if
display text "hello world" (this action part should be where jump to 4 action parts forwards goes)


Wait Actions

Some action parts have an additional option called wait, which enabled will tell the engine to pause the action list until the action or animation has finished. These wait options are optional & can also be very useful for controlling the timing of when certain events should occur.

Play Animation and wait

This will pause the action list that you execute this action in until the animation finishes, however you do need to be careful not to use this option on animations that are set to infinite loop as the action list will be paused indefinitely due to the animation never ending.


Wait until Sound is Finished

This action part will pause the action list that you execute this action in until the linked sound stops playing, however just like play animation and wait you need to be careful that you don't link to a sound that is looping as the action list will be infinitely due to the sound never ending.