Skip to content
We're expanding our documentation. Not all guides are available yet. πŸ› οΈ
Guides
πŸ“ƒ Event System

Event System

In 3Engine, events determine the logic of a game. You can utilize events to establish cause and effect. For instance, an event could identify when the player collides with a collectible item and, consequently, increase the player's score. You can generate and handle events through the Events editor.

πŸ’‘

Note : You don't need to have prior knowledge in programming to create events. However, if you are familiar with programming, you may find some of the concepts to be familiar as well.

Event Structure

Events consist of conditions and actions.
Conditions are used to trigger actions and specify which objects or instances of an object are affected by the event. For example, a condition can check if the player is colliding with another object. In this case, the actions in the event will only occur when the objects are touching each other, and they will only impact the colliding objects.

πŸ’‘

Note: If an event has no conditions, the associated actions will run every frame of the game, typically occurring 60 times per second.

Actions are the actions that occur when all conditions are true.

Examples of actions include deleting an object or incrementing the value of a variable. Without actions,events do not have any effect.

Events can have multiple conditions and multiple actions. For instance, an event may have a condition that checks if the player is jumping and colliding with an enemy object, and an action that deletes the enemy object and increases the player's score.

Event Execution Logic

Execution order

Events are executed in the order they are listed, from top to bottom. The order of events can greatly influence their outcomes.
If you encounter an unintended side-effect caused by an event, make sure to check if any events listed above it in the event sheet are affecting events defined later in the frame.

Object Picking

When a condition refers to objects, the game needs to determine which object instances will be affected by any subsequent actions and subevents. This process is known as object picking.
By default, actions and conditions will affect all instances of the object in the scene. However, conditions (and a limited number of actions) can be used to "filter" or "pick" specific objects that subsequent actions or conditions will apply to.

TimeDelta

3Engine evaluates events and re-renders objects multiple times per second. The frequency of these evaluations depends on the computer's resources. On a slower computer, a game may run at 25 frames per second, while on a faster computer, it may run at a maximum of 60 frames per second. Although 3Engine strives to maintain a consistent frame rate across computers, the frame rate can still vary, resulting in inconsistent operation speeds. To illustrate this, let's consider the following scenario:

events

This action increments a variable in each frame. If the game runs at 60 frames per second, the variable will reach a value of 18,000 after 10 seconds. However, if the game runs at 25 frames per second, the variable will only reach a value of 7,500 after the same 10 seconds. This inconsistency significantly impacts the player's experience.

To address this issue, 3Engine provides the TimeDelta() expression. This expression returns the number of seconds that have elapsed since the previous frame. You can utilize this expression to ensure that the game runs consistently across different frame rates. For example, consider the following action:

events

This action also increments a variable in each frame, but the value of the variable is multiplied by TimeDelta(). This ensures that the variable increments at the same speed, regardless of the frame rate. Consequently, all players will have a consistent experience.

πŸ’‘

Tip: As a general guideline, use TimeDelta() when you need to increase or decrease a value over a specific period of time. If your action only runs once, using TimeDelta() is not necessary.

Create an Event

Adding an event to the event sheet

  1. Open the Event Sheet.
  2. Select the 'Add a new event'.
  3. Select the type of event.
πŸ’‘

Tip: Right-clicking this item will display all types of events. Choosing any special event type from either list will create that event type instantly.

events

Adding conditions to the event

  1. Select 'Add condition' on left side of event.
  2. Select the condition you desire.

events

Adding actions to the event

  1. Select 'Add action' on right side of event.
  2. Select the action you desire.

events

Creating a sub-event

πŸ’‘

Note: Some types of events can have sub-events. Sub-events are events that exist within other events. These types of events only run when: - The conditions of the parent event are true. - The actions of the parent event have been processed.

  1. Select an existing event or create a new event.
  2. Select the 'Add a sub-event to the selected event' icon.

events

πŸŽ‰ Congratulations! You have successfully created an event.