Introduction to the Logic System

Discussion in 'Besiege: Guides Tutorials' started by Von, Dec 8, 2017.

  1. Von

    Von Administrator Staff Member

    So let’s start off with the basics..

    What is the logic system?

    The logic system is used to make things happen in the level you are creating, whether that means opening a gate as you approach it or getting the “Level completed” effect as you destroy a specific object. It basically allows players to script events in the game without any programming or coding knowledge.

    So how does it work?

    The Logic System works very simply, first you create a Trigger and then you create an Event that occurs when the Trigger is activated, for example if an object is destroyed the level is completed.

    The best way for me to explain how the logic system works is by showing you, so I’m going to run through a couple of examples here to explain how it all comes together!

    Example One - Destroy The Village

    I thought we’d start with the most basic example possible, one which features in Besiege’s First level, where the player must destroy some buildings to complete the level.

    So first we need to design our level layout. Here's one I made earlier…


    The goal of this level will be to destroy the 3 buildings in this peaceful farming hamlet. I will therefore need to edit each of the building’s logic to add progression towards completing the level when they’re destroyed.

    Using the “Modify” tool in the Level Editor Panel, I select one of the buildings like and click the Logic tab.


    As you can see, the house currently has no logic attached to it. I want a bit of the level’s progress bar to be filled up when this building is destroyed so I’ll need to add a Trigger with an Event attached to it. The Trigger will be the building being destroyed and the Event will be the Progression Bar partially filling up.

    To add this logic to the object I start by clicking the “+ ADD EVENT TRIGGER” button.


    This has now added a Trigger to the object and allows me to create one or more Events attached to said Trigger. Notice at the bottom I can also create more Triggers with their own events attached to them if I so wish.

    Next, I need to decide the type of trigger I want to use for this bit of logic, the default one is “ON ACTIVATE” which isn’t what we need so I hover over it with my house and use the side arrows to cycle through until I get to the trigger I need “ON DESTROY”.


    Now that I have the correct trigger selected I can add an event that will happen if the building is destroyed, so I click the “+ ADD EVENT” button and select “Increase Progress”.


    If there was only one building in the level I would change the Increase Progress event to increase the bar by 100% but my level has 3 buildings and I want them all to be destroyed before the level can be completed, therefore I’ve set the progress to be 34% (To ensure we don’t get stuck at 99% progress) for destroying this house.

    I then add the same logic to the other buildings in my level and I’m done! Now when the player destroys all the buildings in my village the level is completed!



    Example Two - Destroy Opponent

    This next example is for a multiplayer PVP battle between two players.

    The Multiverse update has an optional damage system for machines which allows you to display health bars above machines and use logic to pronounce a winner of PVP Battles.

    First I create two Build Zones. Next I’m going to assign each Build Zone to a specific team, one to the red team and the other to the green team. When a player selects a build zone (or is placed in one upon joining the server) they are automatically assigned to the team that Build Zone belongs to.

    To assign the Build Zones to different teams I open select the MODIFY tool, from the level editor panel, and click on them. At the bottom of the newly opened window I can select the team which the Build Zone belongs to.


    Once the Build Zones are assigned to different teams I need to add a bit of logic to them for my game mode to work. Under the Logic tab I create a new Trigger and set the type to ON MACHINE DAMAGE. This trigger’s event is activated when the machine from this Build Zone takes the specified amount of damage.


    I’ve set the damage value to to be 50% rather than 100% because I feel requiring the player to destroy every single block and joint could be tedious. I feel if a machine has taken 50% damage it’s probably disabled enough to give the other player victory.

    Next I need to add an event to this trigger. I want the event to be that the opposing player wins the game if this player’s machine takes 50% damage, so I will set the event to be INCREASE PROGRESS and set the value to be 100%


    We also need to set which team should gain progression if the event is triggered. We do this by clicking the little person icon until its the colour we need, which is red for the green team's build zone and green for the red team's build zone.


    Once I’ve applied this logic to both boundary boxes it should result in one player winning the game if their opponent takes 50% damage.



    The logic system can be a very powerful tool for you to create complex levels with dynamic environments and interesting game modes. The examples given in this guide are very basic but in the future I hope to give more advanced uses of the logic system to create game modes such as football or king of the hill, and intractable levels with traps or puzzles. The Logic editor is a powerful tool and we can’t wait to see what you guys create with it!
  2. Steamzombie

    Steamzombie Member

    Thanks for the tutorial. I would like to see a guide some time that explains how you would go about making a domination mode where you capture three points by a) staying on them for a time or b) destroying things (like a village) in them, upon which they will be restored, and as long as a point belongs to your team it generates progress.
  3. Grayandgrayer

    Grayandgrayer New Member

    One thing thats been bothering me is the boost insignia, I don't know how to edit the variable to change the speed of the machine when the thing is crossed by a machine. Please help! :mad::mad:
  4. Sanpyr

    Sanpyr Active Member

    as far as I know, variables don't do that, they are more for 'advanced' things
  5. Von

    Von Administrator Staff Member

    I intend to put together a whole bunch of tutorials on different things :)
    vaporuva and Steamzombie like this.
  6. TomGames Channel

    TomGames Channel New Member

    How can i add weather to my level, like rain or snow?
  7. vaporuva

    vaporuva New Member

    I am very curious about how to make an event dependent on two(or more) events to happen. Like kill A and B to activate C.
  8. ITR

    ITR l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ Staff Member

    Make both add to the same variable on death, then make an event trigger when the variable reaches 2
  9. Sanpyr

    Sanpyr Active Member

    the clouds have options for rain and thunder, no snow yet afaik (cmon guys its December :p)
  10. TomGames Channel

    TomGames Channel New Member

    hmm weird, i was playing on a server and I saw the weather change to snow...... it wasn't the mountain map....
  11. Sanpyr

    Sanpyr Active Member

    the wind effect has some snow-like particles, it might have been that
  12. Steamzombie

    Steamzombie Member

    If you want a speed boost, try activating some wind.
  13. Nels0

    Nels0 New Member

    I'm currently tackling a variety of gamemodes (races with checkpoints, sumo etc) and I have some feedback.

    - Make clear whether trigger is globally single-use or player-local single use
    - Circular trigger area
    - Function to count number of blocks (Failing that, the ability to select starting blocks by team or type (i.e the tag icon))

    What do uninitialised global variables default to?
    Does the chain icon for multiple conditionals mean logical AND/OR?

    More hover text would be very nice

    A way to track custom variables would be f*****g useful too
    Last edited: Dec 19, 2017
  14. Steamzombie

    Steamzombie Member

    You might want to move that post here:
    Not sure what you mean by these two. could you elaborate?
    Zero (Nil).
    Agreed. Variables should be displayable like timers.
  15. Daniel Peñaranda

    Daniel Peñaranda New Member

    So guys, there is some way you can create stuff using logic? like soldiers or trees?
  16. Sanpyr

    Sanpyr Active Member

    you can't spawn stuff in, but you can activate it, which basically just makes it appear (a deactivated object is intangible and invisible)
  17. Displayter.

    Displayter. Member

    is there a way to make the big gate (called "Gates")open and close?
    and if it doesn't already why not add it?would only make sense.
  18. TheNewKid

    TheNewKid New Member

    Couldn't you activate a wind thingy so that the player is boosted then deactivate it?

Share This Page