O'Reilly logo

Mastering Unity 2D Game Development - Second Edition by Simon Jackson, Ashley Godbold

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Communicating between GameObjects

In any game, there are planned interactions between any components within the game. These could be as follows:

  • Physics collision tests
  • Reacting to being shot or shooting
  • Opening and closing doors
  • Triggers, switches, or traps
  • Two or more characters talking

There are several ways in which you can achieve this, and each has its own particular traits. The selection of the implementations depends on what you need to achieve. The methods are as follows:

  • Delegates
  • Events
  • Messaging

In this section, we will go through each method in detail and highlight the best uses of each.

Delegates

We encounter delegates in our everyday lives. Sometimes they are managers, sometimes they are subordinates, and they could even be the barista at your ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required