Index: code/branches/waypoints/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/waypoints/src/orxonox/controllers/FormationController.cc	(revision 9104)
+++ code/branches/waypoints/src/orxonox/controllers/FormationController.cc	(revision 9105)
@@ -276,10 +276,8 @@
 		if(coord.x < 0.0001 && coord.y < 0.0001)
 		{
-			// I AM HERE
-			Vector3 v_temp = this->getControllableEntity()->getOrientation();
-			Quaternion quat = v_temp.getRotationTo(target) * v_temp;
+			// if the ship reaches a direction very close to the direct one, set it to the direct one
+			Vector3 v_temp = this->getControllableEntity()->getPosition();
+			Quaternion quat = v_temp.getRotationTo(target);
 			this->getControllableEntity()->rotate(quat);
-			
-			//this->getControllableEntity()->setOrientation(this->getControllableEntity()->getPosition().getRotationTo(target) * this->getControllableEntity()->getOrientation());
 		}
 
@@ -318,25 +316,25 @@
 
         if(this->state_ == SLAVE)
-        {
-
-           this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2);
-           this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2);
-
-            if (distance < 300)
-            {
-		 if (bHasTargetOrientation_)
-		    {
-			copyTargetOrientation();
-		    }
-                if (distance < 100)
-                {   //linear speed reduction
-                    this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER);
-		   
-                } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
-
-            } else {
-                this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f);
-            }
-        }
+		{
+
+			this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2);
+			this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2);
+
+			if (distance < 300)
+			{
+				if (bHasTargetOrientation_)
+				{
+					copyTargetOrientation();
+				}
+				if (distance < 100)
+				{ //linear speed reduction
+					this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER);
+
+				} else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
+
+			} else {
+				this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f);
+			}
+		}
 
         if (distance < 10)
@@ -391,5 +389,5 @@
     void FormationController::searchNewMaster()
     {
-        if (this->state_==SLAVE) 
+        if (this->state_==SLAVE)
            return;
         if (!this->getControllableEntity())
@@ -402,5 +400,5 @@
         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
         {
-           
+
             //same team?
             Gametype* gt=this->getGametype();
@@ -487,5 +485,5 @@
 	         bool left=true;
             int i = 1;
-	    
+
             for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
             {
@@ -498,5 +496,5 @@
                     i++;
                     dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK);
-                }		
+                }
                 (*it)->setTargetOrientation(orient);
                 (*it)->setTargetPosition(pos);
@@ -607,10 +605,10 @@
 
         if (this->state_==SLAVE)  //become master of this formation
-        {   
+        {
             this->slaves_=this->myMaster_->slaves_;
             this->myMaster_->slaves_.clear();
             this->myMaster_->state_=SLAVE;
             this->myMaster_->myMaster_=this;
-            
+
             //delete myself in slavelist
             std::vector<FormationController*>::iterator it2 = std::find(this->slaves_.begin(), this->slaves_.end(), this);
@@ -655,5 +653,5 @@
            if (i>=slaves_.size()/2) break; //half the formation should attack.
        }
-    }     
+    }
 
 
@@ -868,5 +866,5 @@
     void FormationController::setTargetOrientation(const Quaternion& orient)
     {
-        this->targetOrientation_=orient;	
+        this->targetOrientation_=orient;
         this->bHasTargetOrientation_=true;
     }
