Shared SetDirection code