Design the situation so retreat is impossible and courage stops depending on how you feel that day.
The most reliable way to change what a person does is to remove what they can still do instead. Hands holding a torch and a trumpet cannot also hold a sword, so three hundred men were locked into a strategy they had no physical ability to abandon halfway.
That is a must engineered into the situation rather than held in the mind, and the panic that tore through the camp was released by men who had made their own retreat impossible first. Leaving the means of retreat within reach costs a person the commitment itself, because the fallback gets used and afterward gets called prudence.