I have a bird entity that needs different update rules when it's moving or dying (among potentially other states).

I want to avoid making my `Update` method a clutter of if-else branches like this:

```
void Update() {
   if(state == movingState) {
       // Do moving logic.
   else if(state == dyingState) {
       // Do dying logic.
   else if...

```

Instead, I thought I could make a base class for all my bird behaviours, then derive classes for each state with their own update functions, and use the appropriate derived version based on the current state.

```
public class BirdBaseModel : MonoBehaviour
{
    void Update()
    {
        // ...
    }
}

public class BirdMoving : BirdBaseModel
{
    void Update()
    {
        // ...
    }
}

public class BirdDying : BirdBaseModel
{
    void Update()
    {
        // ...
    }
}    

```

My `BirdBaseModel` is attached to the bird game object. Based on game states, I want to dynamically reference it in the `GameController` class.

```
BirdBaseModel b;

if(State == 1)
{
    b = new BirdMoving();
}
else if(State == 2)
{
    b = new BirdDying();
}

```

Based on the above logic, I want to call the Update function of that particular class. How do I invoke the Update of the subclass?