User Tools

Site Tools


developer_center:developer_editor:example_of_using_trigger:random_parkour

Example of using trigger:Random Parkour

After reading through the whole section of this guide, you can master the following points:

  • How to use variable in trigger
  • How to make a random parkour by using trigger

1.Introduction:How to use trigger

Click Here to know about how to use trigger.

2.Introduction:What is variable

In the game, we can simply understand that a variable is an object used to store a variable value, which is convenient for quickly finding and using the value in the game logic. For more details about the concept of “variable”, please refer to This guide.

3.Learning how to make a random parkour

a.Setting of the stage and the starting area of the parkour

1.Set several parkour stage.The facing of the parkour stage should be the same.

2.Set a region around each of the parkour stages by using tool mode. Click here to know about how to use tool mode. Make sure that all the length and width of the region should be the same, but the height of the region might not be the same.(In this guide, the length and the width of all the regions is 9 and 15 respectively.) Check the position of the starting point and the end point in the region, it should be the same as the position in the following image.


3.Set a starting area according to the following image. The length of the starting area and the parkour stage should be the same, but the width might not be the same. (In this guide, the length and the width of the starting area is 9 and 5 respectively.) Also, put a prep point, public initial spawn point and public spawn point on the starting point.

4.Set two locations. The first location should be set anywhere that the player can touch when the player is at the starting area, and we can rename it as “game start”. The second location should be set at {same as the length side of the starting point, same as the height of the starting point, same as the width side of the starting point +1}, and we can rename it as “starting point”. You may set the locations according to the following image.

b.Variable

Open Developer Tools → Trigger → Variable Library, now we are going to set some variables that we need. The following table shows the variable that we need to use:

Global/Private Variable Variable Name Variable Type Default Values Note
Global Variable create new parkour Area No Default Value N/A
Global Variable stage Value 0 N/A
Global Variable parkour type Value 0 N/A
Global Variable length of stage Value 15 Please set the default values according to the length of region you set at Part a 2.
Global Variable width of stage Value 9 Please set the default values according to the length of region you set at Part a 2.
Global Variable completed stage Numerical group N/A N/A


c.Trigger: Starting of the parkour

After the game starts, we want the player to click a block so that the first parkour stage will be created. Here is a trigger to create a block on the starting area:

Trigger name: When game start
Event:
Triggered when the game is created
Condition:
N/A
Action:
Create [Fluorescent Crystal Block]*¹ on [game start]*² orienting [East]
Create [Textbox ''Textbox content: <Click the block to start the parkour!> , Font size: <16> , Background Opacity: <0> %, ID: <1> ''*³] on [Location Offset (Original location fixed) ''<game start> shifts along the coordinate axis <0> , <1> , <0>'' ]

Note: *¹:You may choose the block you like
*²This is the first location that is set at Part a 4..
*³You may set the details of the textbox yourself.



Then, we need to code a trigger about what will happen after the player clicks the block. Here is the trigger we need:

Trigger name: Start the parkour
Event:
Any players tap on the block
Condition:
[Block type in event] [Yes] [Fluorescent Crystal Block]*⁴
Action:
Destroy the block on [Event Position]
Delete [Textbox] with ID of [1] on [Location Offset (Original location fixed) ''<game start> shifts along the coordinate axis <0> , <1> , <0>'' ]
Play [Light Effect32] on [Event Position], the size is [1]
Run [Randomly choosing]*⁵ , check if condition is TRUE, then run action*⁶

Note: *⁴The block here is which you choose at *¹.
*⁵This is the name of a trigger.
*⁶More information about this action will show in the following paragraphs.



d.Trigger:Create the stage

API: Copy blocks in Area and place them in target area

By using this API, you can clone the block in the area to another, The specific use cases are as follows:

Trigger name: Trigger1
Event:
Triggered when the game is created
Condition:
N/A
Action:
Copy all blocks in [Region1] , place in [Location1]  and orienting [East]

[Region1]:Parameter, the type is Area.
[Location1]:Parameter, the type is Location.
[East]:Parameter, the type is Orientation.

How to create the stage

We will create the stage by using the stage we built before, and copy it by using the API “Copy blocks in Area and place them in target area”.

First, we need to choose which stage will be copped. We will first set the value type variable “parkour type” randomly. Here is the trigger we need:

Trigger name: randomly choosing
Event:
N/A
Condition:
N/A
Action:
Set [parkour type] as [Random Number ''Generate number between <1> and <5>*⁷'']
Wait for [0.05] seconds, and continue to perform the next action.
Run create [parkour no.1]*⁸ , check if condition is [TRUE] , then run action*⁹
Run create [parkour no.2]*⁸ , check if condition is [TRUE] , then run action*⁹
Run create [parkour no.3]*⁸ , check if condition is [TRUE] , then run action*⁹
Run create [parkour no.4]*⁸ , check if condition is [TRUE] , then run action*⁹
Run create [parkour no.5]*⁸ , check if condition is [TRUE] , then run action*⁹

*⁷This number is according to the amount of parkour stage you build.
*⁸This is the name of a trigger.
*⁹More information about this action will show in the following paragraphs.


Then, we need to create the parkour stage. Here is the trigger we need:

Trigger name: create parkour no.1
Event:
N/A
Condition:
[parkour type] [Equal to] [1]
Action:
Copy all block in [parkour no.1] , place in [Location Offset (Original location fixed) ''<starting point> shifts along the coordinate axis <0> , <0> , <{length of stage} {Multiply} {stage} >'']
Wait for [0.05] seconds, and continue to perform the next action.
Set [stage] as [Numerical Operation''<stage> <Add> <1>'']





Then, we need to copy this trigger several times. The amount of trigger is according to how many parkour stages you build. After that, you need to change some content of the trigger:
1.Trigger name:Change the “no.x” behind the word “create parkour”.
2. Condition: Change the third parameter (number).
3.Action: In the first action, change the first parameter (region) to another region set at Part a 2..

Here is an example trigger after changing:

Trigger name: create parkour no.2
Event:
N/A
Condition:
[parkour type] [Equal to] [2]
Action:
Copy all block in [parkour no.2] , place in [Location Offset (Original location fixed) ''<starting point> shifts along the coordinate axis <0> , <0> , <{length of stage} {Multiply} {stage} >'']
Wait for [0.05] seconds, and continue to perform the next action.
Set [stage] as [Numerical Operation''<stage> <Add> <1>'']





In this guide, we design 5 parkour stages, so there should e 5 similar triggers.

Then, we need to edit some actions in the trigger “randomly choosing”. You can increase or decrease the number of actions “Run Trigger”, the number should be according to the number of the trigger “create parkour no.x”, which you copy before. Make sure the first parameter (trigger) in the action should not be repeated, you may change the name of each trigger, so you can identify them easier.

However, we can't find any event in these triggers, that means these triggers are just a function. We need an action to run these programs. So, we need to edit some actions in the trigger “Start the parkour”. Change the first parameter (trigger) in the fourth action to the trigger named “randomly choosing”. After the edit, the trigger should be like this:

Trigger name: Start the parkour
Event:
Any players tap on the block
Condition:
[Block type in event] [Yes] [Fluorescent Crystal Block]
Action:
Destroy the block on [Event Position]
Delete [Textbox] with ID of [1] on [Location Offset (Original location fixed) ''<game start> shifts along the coordinate axis <0> , <1> , <0>'' ]
Play [Light Effect32] on [Event Position], the size is [1]
Run [Randomly choosing] , check if condition is TRUE, then run action

e.Trigger:Create new stage

Now, the parkour stage can be created when the player clicks the fluorescent Crystal Block (start the parkour). However, a new parkour stage cannot be created when the player completes a stage. Here is a schematic diagram showing how a new parkour stage is created:

When the player clicks the fluorescent Crystal Block (A), the parkour will be copped by the trigger randomly, and placed it at (i). Then, when the player goes into region (B), the parkour will be copied by the trigger randomly, and placed at (ii)….

However, as the parkour stage will be created forever, we will not set the region and location we need one by one.

For the region where a new stage will be created when the player goes inside, we will use an area variable, so the region can be changed when a new parkour stage is created. Here is the trigger to change the area type variable:

Trigger name: set region for create parkour
Event:
For every 0.05 sec the game runs
Condition:
N/A
Action:
 Set [create new parkour] as [Convert Location to Area ''Set <Location Offset (Original location fixed) {《starting point》. shifts along the coordinate axis ( 《[Round {The round number of /Numerical Operation <width of stage> <Divide> <2>/ , in form of /Downward/ } ] 》 , 《5》 , 《Numerical Operation [ {length of stage} {Multiply} {stage} ] 》 > as center, area with dimensions ( <width of stage> , <5> , <3> ) ''





Then, we need to set a trigger to create a parkour stage when a player completes a parkour stage. Here is the trigger we need:

Trigger name: When player complete one stage
Event:
When any player enters [create new parkour]
Condition:
[stage] [No Equal To] [0]*¹⁰
Action:
Run [Randomly choosing] , check if condition is TRUE, then run action

*¹⁰This condition makes sure that a new parkour will not be created before the game starts (Player clicks the fluorescent Crystal Block).

Also, you may choose to group these two trigger into a trigger, here is the trigger:

Trigger name: When player complete one stage(another method)
Event:
When any player enters [Convert Location to Area ''Set <Location Offset (Original location fixed) {《starting point》. shifts along the coordinate axis ( 《[Round {The round number of /Numerical Operation <width of stage> <Divide> <2>/ , in form of /Downward/ } ] 》 , 《5》 , 《Numerical Operation [ {length of stage} {Multiply} {stage} ] 》 > as center, area with dimensions ( <width of stage> , <5> , <3> ) ''
Condition:
[stage] [No Equal To] [0]*
Action:
Run [Randomly choosing] , check if condition is TRUE, then run action

However, the first method (use two triggers) is more stable than the second method (use one trigger).

4.More idea to improve the random parkour

Congratulations! You complete a random parkour! However, we cannot say this is a completed game, as players will feel bored after playing it for a short time. Therefore, here are some suggestions for you to improve your map.

Note: In this part, we might just give you an idea, and might not teach you how to do it directly. Try to do it yourself, feel free to ask other developers in our Discord server!

a.Ending of the parkour

Now, the parkour stage will create forever. However, players will feel bored about it. Therefore, we need to think about how to end the game. Here are two suggestions about how to end the game.

(1)According to the number of stage

We can create a Shiny Block, when the player completes an amount of stage. In this example, we set the amount of stage that the player will play as 3.

First, we need a triggers to create the Shiny Block, here is the trigger:

Trigger name: create shiny block
Event:
N/A
Condition:
[stage] [Equal to] [3]
Action:
Create [Shiny Block] on [ Location Offset (Original location fixed) {《starting point》 shifts along the coordinate axis ( 《[Round {The round number of /Numerical Operation <width of stage> <Divide> <2>/ , in form of /Downward/ } ] 》 , 《1》 , 《Numerical Operation [ / {length of stage} {Multiply} {stage} ] / {Reduce} {1} 》 ]





Then, we need to edit some of the trigger we code before. Here are the triggers:

Trigger name: When player complete one stage
Event:
When any player enters [create new parkour]
Condition:
[stage] [No Equal To] [0]
Action:
Run [Randomly choosing] , check if condition is TRUE, then run action
Run [create shiny block] , check if condition is TRUE, then run action*¹¹

*¹¹This is the new action created.

Trigger name: randomly choosing
Event:
N/A
Condition:
[stage] [Not Equal to] [3]*¹²
Action:
Set [parkour type] as [Random Number ''Generate number between <1> and <5>'']
Wait for [0.05] seconds, and continue to perform the next action.
Run create [parkour no.1] , check if condition is [TRUE] , then run action
Run create [parkour no.2] , check if condition is [TRUE] , then run action
Run create [parkour no.3] , check if condition is [TRUE] , then run action
Run create [parkour no.4] , check if condition is [TRUE] , then run action
Run create [parkour no.5] , check if condition is [TRUE] , then run action

*¹²This is the new condition created.

Finally, we need to set the game rules. Open Developer Tools → Basic to set the game rule. Here are the rules we need to set in this part: 1.In “Map Rules” → “Game Target” → “Scoring Setting”, set the number of scores of “Score on collecting stars” to a number which is larger than 1. (In this guide, we set it as 1.) 2.In “Map Rules” → “Game Target” → “Scoring Setting”, switch on “Reach score to win”, and set the number of scores of “Score Requirement” to the same as the number of scores in “Score on collecting stars”. (In this guide, we set it as 1.)

Congratulations! You set the ending of the game!

Additional idea: You may set a system for players to choose how many stages they want to play, by using block, UI library or chat box.

(2)According to the stage that each player complete

1.Set a timer and limit the game time.
2.Set a trigger to add one score to the player when they complete a stage of parkour.
3.When the game ends, the player with the highest score will win the game.
4.Additional idea: You may set a leaderboard by using a UI library or chat box, so players can see other player's scores easily.

b.Decoration

It is important for us to decorate our map, the most common method is to use blocks. Here are some photos for you to have a reference. Try to use your imagination to decorate it!


Map name:Froggy parkour
UID:36872232


Map name:~✿Rainbow•Parkour✿~
UID:74500159


Map name:Parkour In The House
UID:14275857

c. achievement system

You may set an achievement system, so when a player completes a goal (such as completing 20 stages, playing for 5 minutes etc.), the player can get a reward (such as an item, a title etc.). This can extend the title's longevity and provide players with the impetus to do more than simply.


Map name:'Pakour 100Lv'
UID:197822566

d.Set a developer shop

You can sell different products to the player to earn some revenue. Here is an example of how to set a developer shop. You may also add more different products, and promote them by using triggers. Click Here to know more information. Here is an example of the setting of the developer shop:

e.Design an attractive map title and cover

An attractive map title and cover can increase the chances that the player plays the map. Click Here to know more about how to design map titles and covers.

developer_center/developer_editor/example_of_using_trigger/random_parkour.txt · Last modified: 2023/08/03 06:35 by hyue