It became obvious that Castles were obsolete for defense during the "Italian Wars", 1494-1559.
These were a series of wars in Italy, involving the Italian city states and the French and Spanish.
When Charles VIII of France invaded Italy, in 1494, he brought with him the first highly mobile siege train of cannon. These soon proved to be able to very quickly defeat castles. The city of Monte San Giovanni, in the kingdom of Naples had its city walls and its castle shot to rubble after the defenders killed the French envoys. The French army then massacred the defenders. Many other, previously strong Medieval castles and defenses were demonstrated to be equally vulnerable.
Castles had been shown to be unable to resist modern cannon.
By the 1520s, the "Trace Italienne" or "Star Fort" had been developed as an effective defense against cannon. Over the next 100 years, these forts spread across Europe and around the world.
The castle had been made obsolete by cannon and a new type of fortification, more effective in defending against artillery, had been developed.
http://militaryrevolution.s3.amazonaws.com/Primary%20sources/TraceItalienMR.pdf