Advanced Key and Door tricks

Carry an Egg to a platform to spawn a key that opens a door.

First we need to set up the Door and give it a custom message.

  • 'Press L' and select a door from your Asset Library and apply the 'Door' behaviour.

  • Remove any 'Message Required' messages that are there by default.

  • Add your own 'Message Required' messages 'OpenDoor' and 'CloseDoor'

Although one message will do the job I used separate messages to make things easier to explain.

Next we need to make a key so when it is collectable it will open the door.

  • Place down a key asset and give it the 'Pickable' component.

  • Set the 'Collect action required' to 'Collision'

  • Set the 'Collect Message' to 'OpenDoor'

Now you can collect the key and it will open the door. In this example we want to carry an egg to a platform which will give us the key that opens the door. So lets get that part started.

We have to make the key into a 'Preset'

  • Select the gold key then click the 'Preset button' on the left bar.

  • Click 'Create New Preset'

  • Click the 'Finish button'

Now our gold key is a Preset and can be used in 'Asset Spawner' behaviour or the 'Drop' component to summon it into existence with a message. Lets set that up!

  • 'Press L' and select an egg asset from your Asset Library.

  • Apply the 'Pickable' component.

  • Add a Tag 'Egg'.

  • 'Press L' and select a platform asset from your Asset Library.

  • Apply the 'Asset Spawner' behaviour.

  • Set the 'Use Preset' to 'True' and select the 'Gold Key' 'Preset'.

  • Set the 'Message Required' to 'DetectEgg'.

Since we can't use the same object to send and receive a message at the same time we have to separate the process. We set up the platform to spawn a 'Gold Key' when it receives the message 'DetectEgg'. Now we need to set up an Asset to detect the 'Egg' tag and send the message to the platform.

  • 'Press L' and select a small asset from your Asset Library. We used 'NumPad Switch'.

  • Remove any 'behaviours' and add a 'Speaker' component.

  • Set 'Display condition' to 'DetectEntity'

  • Set 'Target Tags' to 'Egg'

  • Set 'Message When Spoken' to 'DetectEgg'

  • Make the asset 'Invisible' and set Physics to 'No collision'.

  • Move the Asset under the platform where you want the Egg to be detected.

Now when you carry the Egg to the platform the invisible object detects the Egg Tag on the Egg and sends a message to the platform which is an Asset Spawner and Spawns our Preset the 'Gold key'. The player can collect the Gold Key which now opens the door.

As a little bonus! We can set up a detector to close the door once the player walks through which cannot be opened again unless you send another message.

  • 'Press L' and select a small asset from your Asset Library. We used 'NumPad Switch'.

  • Make the asset 'Invisible' and set Physics to 'No collision'.

  • Remove any 'behaviours' and add a 'Speaker' component.

  • Set 'Display condition' to 'DetectEntity' and the 'Detection Range' to '4'

  • Leave 'Target Tags' as 'Avatar'

  • Set 'Message When Spoken' to 'CloseDoor'

Now when the player walks through the door the invisible object will detect the Avatar and send the message to 'CloseDoor' which closes the door. Pretty cool!

Last updated