Knowledgebase / Remotely trigger other scripted game objects
You can remotely trigger scripted game objects by sending messages between them.
Here is an example of where you can use messaging to trigger an in-game event:
The switch will be scripted to send a message to the crates telling them to destroy themselves when the switch is touched.
We can use the “Send every game object a mesage” block to send a message to every game object in the level, but this is only useful if other game objects have a script with the “When I receive message” block.
(Note: the above image is a demonstration of how messages are sent. Your script shouldn’t actually look like that.)
Here’s what the switch script will look like:
The “When I am touched” block is under the Physics category, and the “Send every game object a message” block is under the Events category. Make sure to edit the message by clicking on the blue block.
The crate’s script will look like this:
The “When a message is retrieved” block is inside the Events category, and the “destroy myself” block is from Control. The message will need to be exactly the same, so make sure you spell it the same and use the same capital letters and spaces.
The switch will send the “destroy” message to every game object in the level, and the crates will receive it and destroy themselves.
Try to add more blocks to these scripts to extend upon them!