Simplify direction to motion
Use global.get_current_time() instead of new Date().getTime()