Leadwerks Game Engine

Leadwerks Game Engine

Not enough ratings
Tutorial - Doors
By Aggror and 1 collaborators
This tutorial is an introduction to the flowgraph editor. In this lesson you learn how to set up interaction between doors and using collisions for triggers.
   
Award
Favorite
Favorited
Unfavorite
Intro
In this lesson we learn how to use the build-in flowgraph editor. We will also learn how to interact with doors and collision triggers. Open up the doors.map from the tutorial project. This scene contain 2 doorways. The first door can be opened by pressing a button while the other 2 doors will be opened automatically once the player is near.



Play the game
Walk towards the first big door.


This door can be interacted with. Once the player is close enough, a hand icon will appear. Press E to open the door. Door is no longer active after opening. This is setup vide the flowgraph editor. Which we cover later in this lesson.



Walk to the next two doors. These doors open automatically when we near them.

Sliding door script
Gate
Select the large door in the scene and go to the script tab. You can see that the SlidingDoor.lua script is attached.


There are various settings that define the behaviour of this door. It is currently enabled, which means we can interact with it. The move distance determines where the doors moves towards to when it is being opened The move speed determines how fast the doors opens/closes. We can also specify the opening and closing sounds.

2 sliding doors
The other two doors also have the slidingdoor script attached. You will see that these doors move towards the side instead of going up (like the first door/gate).

CollisionTrigger script
The 2 sliding doors can't be interacted with. That is because we have set it up to interact with a collision trigger. Go back to 4 viewports and select the top viewport. You can see a blue outlined box around the two doors.


The box is not visible because it has the invisible material.If you would want to see the box, go to view-> show physics. Toggle this to hide it again.



The box has the collision trigger script attached to it. However we don't have to set any options for it as we do this in the flowgraph editor.



The Flowgraph editor
To open the flowgraph editor go to Tools -> Flowgraph editor.


The flowgraph editor is used for setting up interaction in a scene. use the middle mouse to move around. Selected objects in the scene tab highlight the script in the flow editor.


You can drag objects in to the flowgraph editor via the scene tab. Objects only appear in the flowgraph editor if they have a script attached. In order to remove an object (called a Node) from the flowgraph editor: right click on the object in the flow editor. Delete removes it from scene and the flowgraph editor while 'Remove node' only removes the node from the flowgraph editor.



We can connect input and outputs to eachother to create events. Click on a little black output dot, hold down the left mouse and drag the mouse to a black input dot.


If you want to remove a connection between input and output you can do this by drag a connection end of the connection in to the grey area of the flow graph editor.

Closing and Opening the gate
Remove the connection between Open() en Disabled(). If we test out the scene and we open the gate, you will notice that this time we can still interact with it. If we look at the, now opened, gate we can see that gate is still active and that the hand icon appears. This means that we can also close it again. Back in editor we connect the open output to the disable input of the same script so that we reset it to its previous functionality.
Two sliding doors
Locate the 'BoxTrigger' in the scene. You can see that the Collisiontrigger script is attached. In the flowgraph editor we can see the 'Collision' output. That means that when there is a collision, the Collision output is called. The output is connected to the Open input from the 2 door script. An Output can connect to as many input functions as you want.

1 Comments
den24 26 Nov, 2023 @ 3:28pm 
thanks!