If the object you want to rotate uses car motion, the behaviour has the expression VectorX and VectorY, which give the movement of the object in each of these axis i.e. it splits the current movement into its perpendicular components. The angle of movement can then be calculated. Taking 0 degrees as the positive x axis, the direction of movement equals:
if x > 0 & y > 0 :
a = arctan(VecX/VecY)
if x < 0 & y > 0 :
a = 180 + arctan(VecX/VecY)
if x < 0 & y < 0 :
a = 180 + arctan(VecX/VecY)
if x > 0 & y < 0 :
a = 360 + arctan(VecX/VecY)
There may not be VectorX and VectorY values for other behavious. You could calculate them basically by storing the last position of the object and comparing it with the new version and finding the difference in x and y. This method may make the rotation rough so you may have to use some interpolation methods to make it smoother.