set a moving trigger over the unit, and set the trigger to activate if you detect the enemy, write the script 'unitname' leavevehicle 'vehiclename';
unitname setbehaviour "combat"
if ur attacking, simply give them a transport unload waypoint
to go more in depth, out all the units in the back of the vehicle in a group, and give the leader a seek and destroy waypoint. in all of the sodiers initilizations, write:
'soldiername' moveincargo 'vehiclename'