If you find your ball in play, but in a circumstance where you are not able to make a swing or advance the ball, then you are always entitled to claim an unplayable lie. Under this rule, you incur a one-stroke penalty, but are permitted to take relief from your troubling situation.
There are three specific options when taking an unplayable lie. The first option is to go back to the point from where you played your last shot. The second option is to drop your ball within two club lengths of where the ball came to rest, without moving closer to the hole. The third and final option is to take the flagstick and the point where your ball came to rest, and move back away from the hole in a straight line as far as you want. These are your only three options when your ball is in a position where you cannot make a swing, or otherwise choose to take relief.
In summary, if you find your ball in a position where you cannot make a swing, or choose to take relief, you have the option to claim an unplayable lie. The penalty for doing so is one stroke. Your three options include going back to the point where you played your previous stroke, taking a drop within two club lengths, or moving straight back anywhere along an extension of a line between the flagstick and where your ball originally came to rest.