Linking object functions

I am creating a game which requires one object to perform a specific action when another (random) object performs the same action. Is it possible (using C#) to create two way communication between objects using handlers or the like?

In other words, when I rotate Object A by 90 degrees, Object B also rotates 90 degrees but in another scenario, it may be that when Object A is rotated 90 degrees, it’s Object C that’s required to rotate 90 degrees, and not Object B.

I hope I’ve made clear what I’m trying to accomplish.

You could for example store the list of the objects in a script and when you need to get another random object use a function from there.

For example:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class ObjectsList : MonoBehaviour {

	public static ObjectsList instance;

// Drag all the available objects here from hierarchy panel
// or else use FindObjectsOfType<YourScriptName>() in Awake or Start
	public GameObject[] allObjects;

	void Awake () {
		instance = this;
	public GameObject GetRandomObject (GameObject excludeMe) {
		List<GameObject> list = new List<GameObject>(allObjects);
		return list[Random.Range(0, list.Count)];

Then in your script attached to the object you’ll call the following line and apply your rotation or everything else to it:

GameObject randomObject = ObjectsList.instance.GetRandomObject(gameObject);