Well, the rattler--or any pit viper--zeroes in on heat. Their two heat-seeking pits function as do our eyes, providing a sort of depth perception.
A gun-barrel, being probably warmer than the air, gives them a heat source to zero in on.
An instance where a survival mechanism can be contra-survival.
, Art