Peace be upon you.
Ayatollah al-Uzma Sayyid Sistani (may Allah protect him):
It is required that the place of the obligatory prayer allows the worshipper to be stable and not in a state of disturbance that prevents them from standing, bowing, or prostrating. It is also advisable to ensure that the body is calm, meaning that the worshipper should not be on a moving animal or swing. However, it is permissible to pray on a stationary animal or ship if stability is achieved as mentioned. If they are moving but stability is attained, then it is also permissible. The same applies to cars and trains; prayer is valid in them if stability and facing the Qibla are achieved. If any of these conditions are missed, it is only permissible in cases of necessity, and in such cases, the worshipper should turn towards the Qibla whenever the vehicle turns. If one cannot face the Kaaba directly, they should be between the right and left. If one can only face it during the opening Takbir, they should do so, and if they cannot face it at all, the prayer is waived. The same applies to those who are walking or have other valid excuses. It is permissible to board a vehicle or ship before the prayer time begins, knowing that one will have to pray in it without fulfilling the conditions of facing the Qibla and stability.
Ayatollah al-Uzma Sayyid Khamenei (may Allah protect him):
The place of the worshipper must be stable, meaning that the worshipper should be able to pray calmly and without disturbance. Therefore, prayer is not valid in places that cause the body to move involuntarily, such as in a moving car or train, or on some vibrating beds, except in cases of time constraints or other emergencies that necessitate praying in such places.
Travelers in public transport who fear missing a prayer should ask the driver to stop, and the driver must respond to their request. If the driver does not stop for any reason, the travelers must pray while in motion, taking into account the direction of the Qibla and performing standing, bowing, and prostrating as much as possible.
May you be successful in all good.