4 way teleport system - Refined
The teleport system just got better and easier to make with 4 spawn locations and only 1 message required and no more bugs. Let's dive straight into it.
- Place a basic asset to use as buttons. In this example we used 'NumPad Switch'
- Add the 'Asker' Behaviour to the asset.
- To make things simple give the 'Answer' and 'Message sent' to 1,2,3,4 (see below image)
- Duplicate CTRL+D the asset 3 times and place them where you want to teleport to and from.
Now let's set up how the Avatar dies and respawns.
- Click 'GLOBAL PARAMETERS' button at the top of the screen
- Click 'CONTROLLER'
- Click 'COMPONENTS'
- Change 'Death Event' to 'RespawnToTag' and 'Death Delay' to '-2'
- Change 'Respawn Tag' to 'spawn1' and 'Instant death message' to 'Killx'
Now to create a preset to make this all work.
- Put down 2 'NumPad Switch' assets next to each other near a button we created earlier.
- Name one of them 'SPAWNER' and the other 'SPAWNERKiller' and make them both 'No collisions'
- Select the 'SPAWNER' asset and add 'Message Broadcaster' Behaviour.
- Set 'Visible' to 'False' and 'Message to Send' to 'Killx'
- Set 'Broadcast Only Once' to 'True'
- Add the 'Speaker' Component, delete the 'Text to display' and set 'Display condition' to 'DetectEntity'
- Set 'Message When Spoken' to 'KillSpawn'
- Give a 'Tag' 'spawn1'
- Select the 'SPAWNERKiller' asset and give it a 'Health Component'
- Set 'Death Delay' to '-1' and set 'Instant death message' to 'Killspawn'
- Set 'Life Bar Display' to 'Hidden'
Now we need to parent the assets. Open the 'HIERARCHY' in the bottom left corner.
- Search for 'spawn' to narrow the list.
- Click and drag the 'Target' icon of the 'SPAWNER' to the nameplate of 'SPAWNERKiller' to parent the object. Make sure you do it the right way around. Check image below.
While the 'SPAWNERKiller' asset is selected press the 'Preset' button on the left and create a new Preset.
When the preset is made you can go ahead and delete those 2 assets as they are now saved as a preset. NOTE: Sometimes you need to reset the whole Game Maker to see/use new preset.
Last thing we need to do is spawn the preset at each of the locations we need.
- Put down a new 'NumPad Switch'
- Give it 'Asset Spawner' Behaviour and set physics to 'no collisions'
- Set 'Visible' to 'False'
- 'Use Preset' to 'True' and select the preset we made 'SPAWNERKiller'
- Set 'Message Required' to '1'
Duplicate the 'Asset Spawner' with CTRL+D and drag it to another spawn location and change the message required to '2'. Do it again for '3' and '4'
That's it! You now have a fail safe 4 way teleport system. How easy is this?