The opportunity cost of capital of a company increases as it takes riskier projects.
Company A wants to build a new factory. It requires 10 lakhs capital to build this factory. Company A does not have so much capital available so it wants to borrow this amount from the market in the form of debt. Suppose bank B lends this amount to A. B requires return of 10% on this amount. So opportunity cost of capital for company A for this project becomes 10%.