title: How to avoid type checking every frame?
body: <p>I'm writing a vehicle controller that  issupposed to be able to handle multiple different vehicles types instead of using inheritance so I can keep the amount of classes to a minimum.  I'd like to remove the constant type checking every fixed frame but I'm not sure how to go about this.</p>
  
  <pre><code>private void FixedUpdate()
  {
      if (VehicleSchema is VehicleSchema_AFV.Hovercraft)
      {
          UpdatePosition(transform.forward, false);
          UpdateYawRotation(false);
          AlignToTerrain(false, false);
  
          VehicleSchema_AFV afv = (VehicleSchema_AFV)VehicleSchema;
          UpdateTurretRotation(afv.TurretObj);
      }
      else if (VehicleSchema is VehicleSchema_AFV.Wheeledcraft)
      {
          UpdatePosition(transform.forward, false);
          UpdateYawRotation(true);
          AlignToTerrain(true, true);
  
          VehicleSchema_AFV afv = (VehicleSchema_AFV)VehicleSchema;
          UpdateTurretRotation(afv.TurretObj);
      }
      else if (VehicleSchema is VehicleSchema_AFV.Trackedcraft)
      {
          UpdatePosition(transform.forward, false);
          UpdateYawRotation(false);
          AlignToTerrain(true, false);
  
          VehicleSchema_AFV afv = (VehicleSchema_AFV)VehicleSchema;
          UpdateTurretRotation(afv.TurretObj);
      }
      else if (VehicleSchema is VehicleSchema_Mech)
      {
          UpdatePosition(transform.forward, false);
          UpdateYawRotation(false);
          AlignToTerrain(true, false);
  
          VehicleSchema_Mech mech = (VehicleSchema_Mech)VehicleSchema;
          UpdateTurretRotation(mech.TorsoObject);
      }
      else if (VehicleSchema is VehicleSchema_Aircraft.VTOL)
      {
          UpdatePosition(transform.up, true);
          UpdateYawRotation(false);
          UpdatePitchRotation();
          UpdateRollRotation();
  
          VehicleSchema_Aircraft.VTOL vtol = (VehicleSchema_Aircraft.VTOL)VehicleSchema;
          UpdateTurretRotation(vtol.TurretObj);
      }
  }
  </code></pre>