/// <summary> /// Calls custom cargo plane into action /// </summary> /// <param name="targetPosition">Position to drop item to</param> public CargoPlane CallPlane(Vector3 targetPosition) { // Create cargo CargoPlane cargoPlane = CreatePlane(); cargoPlane.Spawn(); cargoPlane.name = "Bang Bang Cargo Plane"; cargoPlane._name = "Bang Bang Cargo Plane"; // If we don't specify the target position, then a random position is used if (targetPosition == null) { targetPosition = cargoPlane.RandomDropPosition(); } // Create custom cargo plane, init and set custom airdrop on position reached _airbornePlane = cargoPlane.gameObject.AddComponent <SpecialAirdropPlane>(); _airbornePlane.InitializeFlightPath(targetPosition); _airbornePlane.PositionReached += PositionReached; return(cargoPlane); }