Sinkage and trim, which often occur to ships moving in shallow water, do not only have an effect on the ship–ship hydrodynamic interaction forces but also increase the risk of grounding. Potential flow-based online calculation of ship–ship hydrodynamic interaction forces without accounting for dynamic sinkage and trim is able to capture the hydrodynamic interaction effects with fair accuracy; however, there are still discrepancies in many cases, especially in the case of shallow water. An algorithm based on the potential theory has been devised for real-time simulation of the hydrodynamic interaction between two ships in shallow water accounting for sinkage and trim. The shallow water condition is modeled using the mirror image method. The sinkage and trim are solved iteratively based on the principle of hydrodynamic balance, where a mesh trimming procedure is carried out when the waterline is changed. Simulations are performed with and without accounting for the sinkage and trim, and comparison with experimental results shows a fair agreement.