How Events and Rules Work Together

HOW EVENTS AND RULES WORK TOGETHER
Game development is an exciting field, that offers you the opportunity to create immersive and interactive experiences! One of the most important aspects of working with the Verse Language in UEFN will be understanding how events and rules work together to produce actions in-game.
Now if you are new to coding, like me, then this will be beneficial. Once I realized how to understand these two concepts of game programming, it became a bit easier to grasp! So I hope it does for you too!
WHAT ARE RULES
The first component involved in producing actionable results from events is a ruleset, which is a collection of instructions used by developers when creating logic and behavior systems. Rulesets allow developers to define how characters interact with each other, what items do/can't do under certain circumstances, and more. For instance, if two characters meet on screen then one might have higher class/priority over another - this would be defined within a rule set so it's clear what set of rules each player will be abiding by. Without proper implementation via ruleset programming, players' interactions with each other or objects onscreen could become chaotic!
WHAT ARE EVENTS
The second component would be events. Events are triggers that can be initiated by players or other elements within a game world. These triggers cause something to happen β like a character moving, objects being interacted with, or even entire levels changing β which allows for different types of gameplay experiences. For these events to take place properly they must be programmed into the codebase as part of an event system; this includes setting up conditions that need to be met before certain actions occur (e.g., the player has enough points - the rule) as well as defining what happens when those conditions are met (e.g., move character forward- the event).
EXAMPLE
Let me show you how rules and events are used with Verse expressions - If and Then. You could use βif-thenβ statements (also known as conditionals) where if certain criteria have been fulfilled then something will happen. For me, since I am new to this as well, I think of it as your everyday cause and effect scenario. Let's take a look at an example code using the If, Then expression.
(source: https://dev.epicgames.com/documentation/en-us/uefn/if-in-verse)
LET'S READ IT OUT
Now if that looks confusing to you, thats ok! Sometimes reading it out makes it easier to understand whats going on! So lets give it a go! :)
If the player's Fall Height is less than 3.0, with a jump meter set or equal to 100.
Then if it all checks out - and succeeds, the player will perform a double jump plus reset the the player's fall height back to zero.
And there you have it! A rule paired with an event - that takes effect based upon that rule! When programming engaging experiences in UEFN with Verse, you may see this used a lot. Some simplistic examples would be in pregames (i.e- if 10 players in lobby, start game) or even gun games (i.e - If players eliminated 3 times, switch to spectate) and can become more complex depending on what it is you need to have done!
By combining both event systems and rule sets correctly, you are able to create dynamic gaming environments where all sorts of interactions between entities make sense according to their roles & relationships - allowing users to enjoy engaging worlds filled with engaging content!
Read more about If, then statements in Verse: https://dev.epicgames.com/documentation/en-us/uefn/if-in-verse
View Community shared code in the UEFN Development Community and see if you can spot some If, Then expressions! https://dev.epicgames.com/community/fortnite/snippets
Join the FCHQ Discord to learn more about UEFN! https://discord.com/FCHQ

.
Comments
You must be logged in to comment.