Leadwerks Game Engine

Leadwerks Game Engine

Not enough ratings
Tutorial - Switches
By Aggror and 1 collaborators
This lesson shows how to open a door by using a switch.
   
Award
Favorite
Favorited
Unfavorite
Intro
This lesson teaches you how to set upinteraction between aswitch and a door. For this lesson we use the Switches and events scene from the tutorial project.




The switch
The game starts with the FPS character. We want to open the gate via the switch hanging on the wall. The handle of the switch rotates when the switch is used.



Locate the switch in the scene tab. You can see that the switch exists out of a base and a handle.



The swiningdoor script is attached to the handle. When we go to the script tab you can see that the handle rotates on a specific axis. The door has the sliding door script attached.

Let's play
When we start the game we walk towards the switch. When we are close to the, the hand icon appears.



Press E to interact with it. The gate opens and the switch handle rotates 90 degrees.



Interact again and door closes.

Flowgraph editor
Go to the flowgraph editor. As you can see there are two nodes: SlidingDoor and SwingingDoor. The swingdoor is used for the switch and the SlidingDoor for the Gate/Door.


We can also use toggle which executes the action that is needed to revert its current state.
It will do do the exact same thing.




You can see the following connections are set up:
- We are closing the switch, we close the door.
- We are opening the switch, open the door.

2 Comments
den24 26 Nov, 2023 @ 3:28pm 
thanks!
Пушистый 14 Nov, 2014 @ 11:29am 
stupid