Dinosaurs were at their most vulnerable when they were wiped out by an asteroid impact, a new study has found.
A group of dinosaur experts looked at the extinction of dinosaurs 66 million years ago.
Dr Steve Brusatte, of Edinburgh University, said rising sea levels and volcanic activity had made dinosaurs more at risk of extinction when an asteroid hit Earth.
If it had happened at a different time they might have survived.
Dr Brusatte said that the extinction of the dinosaurs was just "colossal bad luck", and that things could have been different if the timing was better.
There is evidence that some species of dinosaur were dying off shortly before an asteroid hit the Earth, and one key question was whether this would had led to their extinction even if the asteroid had not hit.
However, it was concluded that even though some plant eating species were dying out there was no evidence of a long-term decline.
Dr Brusatte says that if the asteroid had hit a few million years earlier, before the changes on Earth, then the dinosaurs might have recovered and could be walking the Earth to this day.