A comet is a randomly created celestial body usually in orbit around Kerbol, although sometimes they can be found simply passing through the Kerbol System. They first appeared in the game with the release of the Shared Horizons update, or 1.10.
Comets can be found and monitored via the tracking station.
Like asteroids, comets are fully under control of the physics system. They can be rotated or accelerated by the application of torque or thrust, and moved into a different orbit or another body's sphere of influence with correct maneuvering. They do not have SOIs of their own or produce gravity to affect nearby objects; they may not be landed on by craft, stood on by kerbals on EVA, or have flags planted on them, but may be docked with through the use of the Advanced Grabbing Unit.
Comets can be much larger that Asteroids with their classes being Class F: "Huge", Class G: "Massive", Class H: "Gargantuine", or, the largest, Class I: "Gargantuine". Typically, class I is restricted only to "Interstellar" comets, which are already really rare, but most of the time, Interstellar comets in KSP are class H, making a class I "Interstellar" comet one of the rarest things in the game. Their occasional immense size and mass makes them difficult to maneuver with ordinary ships; they are slow to turn and usually extremely heavy. They become even more challenging with their high inclination orbits and highly elliptical orbits, which make it so that you may only get one shot or have to wait for hundreds of years, so if you want to move a comet, you might wanna aim for one of the smaller ones. Fortunately, Kerbals are immortal which means that can survive the ride and as they approach the Kerbol they are in for a great show with two beautiful tails coming off the comet.
Note: of the two tails every comet has when in close proximity to Kerbol (Usually just outside of Duna's orbit is when they will start generating the tails), the colored one (which is usually a dark blue) seems to have a chance of being different colors, though miniscule. In fact, the only other color that I've ever seen is just a lighter shade of blue, making light blue or cyan.
Just like asteroids, you can take samples of comets. The way the sample works is the same as asteroids, too-if you're in orbit of the sun, and move to orbit of kerbin, you can get 2 different samples worth more/less/equal science to each other. The main difference is the amount of science, since every comet type (shown below) has different science amounts, the highest being Interstellar comets.
Comets were added in version 1.10 of Kerbal Space Program. This update also brought a lot of new features in collaboration with the ESA.
Comet types can define size, duration of existence and the amount of science you get from samples. The four comet types seem to be as follows from shortest to longest length of existence: Short period, Intermediate period, Long period, and Interstellar. Short period comets do not last long, (at least on a cosmic scale of time) so if you see one, it may be worthwhile to go check it out as soon as possible. They also tend to have lower orbits around the sun, seemingly having a standard apoapsis of around Jool's orbit, sometimes higher or lower.
Intermediate comets are roughly the same as Short period comets, except they last a bit longer. (again, this is on a cosmic scale, even short period comets last a few years) In fact, they tend to have similar orbits to that of short period comets, though maybe a bit more eccentric and with a higher apoapsis, sometimes a bit past Eeloo's orbit.
Long period comets can last quite a while, even on a cosmic scale. They tend to have highly eccentric orbits that can take hundreds of years to happen. You guessed it, these comets' apoapsis' tend to be extremely far away from the sun-such so that from the comet's perspective, the sun can sometimes just look like one of the many stars in space. These comets can be quite hard to reach, for obvious reasons-they have incredible speed at periapsis and because of this, they at times seem impossible to reach.
However, Interstellar comets are far harder to reach. These comets are unique in the way that they don't orbit the sun-they pass by it, sometimes at incredible speeds. Reaching interstellar comets is an effort and a half, and you're on a timer-if they leave the system before you can reach them, that's a lost opportunity for science-lots and lots of science, too. As mentioned before, these comets are Massive, scaling from class H to class I "Gargantuine" sizes, they're incredibly heavy, and can have only a fraction of their mass in ore (though mining their ore will have a sometimes big effect on their mass), and to top it all off, you have a timer to reach them. So if these massive behemoths fly close to the sun, either enjoy the lightshow while it lasts or take immediate action and make an attempt for it before it's long gone.
Once a comet is captured with the Advanced Grabbing Unit, it is considered part of the ship. It can be renamed when docked, and/or the craft can then use its engines to alter its orbit. This can be used to get it into a stable orbit around Kerbin or another celestial body, or even drop it into the atmosphere and land it. Capturing a comet requires a procedure similar to docking.
The rendezvous is identical to the usual docking- the comet is targeted and orbits are matched. On close approach instead of targeting a specific docking port the center of mass of the comet may be targeted, and the Advanced Grabbing Unit can attach to the comet's surface at any point. Perfect accuracy is not crucial because the Advanced Grabbing Unit can be tilted after contact to align the craft's thrust with center of mass.
Being as heavy as they are, if you intend to move a comet it is advisable to mine it for extra fuel, with the helpful side-effect of lowering the comet's mass.
You can attach struts, science modules, and other surface-mount parts to a comet with an Engineer the same way you can to any other part, although the parts may attach in odd-looking ways.