Index: code/branches/dockingsystem2/data/levels/docking.oxw
===================================================================
--- code/branches/dockingsystem2/data/levels/docking.oxw	(revision 8501)
+++ code/branches/dockingsystem2/data/levels/docking.oxw	(revision 8544)
@@ -35,26 +35,7 @@
 
 
-    <Dock>
-        <animations>
-            <MoveToDockingTarget target="destroyer" position="10,150,40" />
-        </animations>
-        <effects>
-            <DockToShip target="spaceShip" />
-        </effects>
-        <events>
-            <execute>
-                <EventListener event="dockMe" />
-            </execute>
-        </events>
-        <attached>
-            <DistanceTrigger position="0,0,0" distance="30" target="Pawn" beaconMode="exclude" targetname="bcnSpaceShip" name="dockMe" />
-            <Billboard material="Examples/Flare" colour="1.0, 0, 0" />
-        </attached>
-    </Dock>
-
-
-
       <SpaceShip
-   position               = "-150,-50,-100"
+   position               = "280, 150, 115"
+   orientation            = "0.5, 0.5, 0.5, 0.5"
    hudtemplate            = "spaceshiphud"
    camerapositiontemplate = "spaceshipassffcameras"
@@ -117,4 +98,23 @@
         <DistanceTriggerBeacon name="bcnDestroyer" />
         <DockingTarget name="destroyer" />
+
+
+        <Dock orientation="0.5, 0.5, 0.5, 0.5">
+            <animations>
+                <MoveToDockingTarget target="destroyer" position="10,150,40" />
+            </animations>
+            <effects>
+                <DockToShip target="spaceShip" />
+            </effects>
+            <events>
+                <execute>
+                    <EventListener event="dockMe" />
+                </execute>
+            </events>
+            <attached>
+                <DistanceTrigger position="0,0,0" distance="30" target="Pawn" beaconMode="exclude" targetname="bcnDestroyer" name="dockMe" />
+                <Billboard material="Examples/Flare" colour="1.0, 0, 0" />
+            </attached>
+        </Dock>
 
 
Index: code/branches/dockingsystem2/src/modules/docking/DockingController.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingController.cc	(revision 8501)
+++ code/branches/dockingsystem2/src/modules/docking/DockingController.cc	(revision 8544)
@@ -29,4 +29,6 @@
 #include "DockingController.h"
 
+#include <cmath>
+
 #include "infos/PlayerInfo.h"
 #include "worldentities/ControllableEntity.h"
@@ -49,19 +51,78 @@
     void DockingController::tick(float dt)
     {
-        this->moveToTargetPosition();
+        ControllableEntity* entity = this->getControllableEntity();
+        if (!entity)
+            return;
+
+        float distance = (dock->getWorldPosition() - entity->getPosition()).length();
+        Vector2 coord = get2DViewdirection(     // I don't understand this too
+            entity->getPosition(),
+            entity->getOrientation() * WorldEntity::FRONT,
+            entity->getOrientation() * WorldEntity::UP,
+            dock->getWorldPosition()
+        );
+
+        // adjust direction of spaceship
+        if (distance > 10)
+        {
+            entity->rotateYaw(-1.0f * 0.8f * sgn(coord.x) * coord.x*coord.x);
+            entity->rotatePitch(0.8f * sgn(coord.y) * coord.y*coord.y);
+        }
+
+        /*// adjust speed
+        if (distance < 200 && entity->getVelocity().squaredLength() > dock->getVelocity().squaredLength())
+            entity->moveFrontBack(0.2f);
+        else
+            entity->moveFrontBack(0.8f);*/
+
+        entity->moveFrontBack(0.5f * log(distance/10.0f));
+
+        if (distance < 20)
+            this->positionReached();
 
         SUPER(DockingController, tick, dt);
     }
 
+    void DockingController::takeControl(bool docking)
+    {
+        this->docking = docking;
+
+        entity = player->getControllableEntity();
+        assert(entity);
+
+        if (docking)
+        {
+            COUT(0) << "DockingController::takeControl Taking over control." << std::endl;
+
+            entity->setDestroyWhenPlayerLeft(false);
+            player->pauseControl();
+            entity->setController(this);
+            this->setControllableEntity(entity);
+        }
+    }
+
     void DockingController::positionReached()
     {
-        // TODO; Give control back to player
-        PlayerInfo* player = this->entity->getPlayer();
-        assert(player);
+        COUT(0) << "DockingController::positionReached() called." << std::endl;
+
+        assert(this->player);
+        assert(this->dock);
+
+        // stop spaceship
+        dock->attach(entity);
+        entity->setVelocity(0, 0, 0);
+        entity->setOrientation(dock->getOrientation());
+
+        // give control back to player
+        player->startControl(entity);
+        this->setActive(false);
+        this->controllableEntity_ = NULL;
 
         if (docking)
             dock->dockingAnimationFinished(player);
-        else
-            dock->undockingAnimationFinished(player);
+        /*else
+            dock->undockingAnimationFinished(player);*/
+
+        this->destroy();
     }
 }
Index: code/branches/dockingsystem2/src/modules/docking/DockingController.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingController.h	(revision 8501)
+++ code/branches/dockingsystem2/src/modules/docking/DockingController.h	(revision 8544)
@@ -50,5 +50,5 @@
 
             void setDock(Dock* dock) { this->dock = dock; }
-            void setEntity(ControllableEntity* entity) { this->entity = entity; }
+            void setPlayer(PlayerInfo* player) { this->player = player; }
 
         protected:
@@ -56,6 +56,9 @@
 
         private:
+            bool docking;
+
             Dock* dock;
-            bool docking;
+            PlayerInfo* player;
+
             ControllableEntity* entity;
     };
Index: code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.cc	(revision 8501)
+++ code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.cc	(revision 8544)
@@ -53,5 +53,10 @@
     {
         assert(parent);
-        parent->dockingAnimationFinished(player);
+
+        DockingController *dockingController = new DockingController(this);
+        dockingController->setDock(parent);
+        dockingController->setPlayer(player);
+        dockingController->takeControl(true);
+
         return true;
     }
@@ -59,5 +64,7 @@
     bool MoveToDockingTarget::release(PlayerInfo *player)
     {
-        assert(parent);
+        //TODO: Investigate strange things...
+        parent->detach((WorldEntity*)player->getControllableEntity());
+
         parent->undockingAnimationFinished(player);
         return true;
Index: code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.h	(revision 8501)
+++ code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.h	(revision 8544)
@@ -38,4 +38,5 @@
 #include "DockingPrereqs.h"
 #include "DockingAnimation.h"
+#include "DockingController.h"
 #include "Dock.h"
 
Index: code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc	(revision 8501)
+++ code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc	(revision 8544)
@@ -213,4 +213,16 @@
     }
 
+    void PlayerInfo::pauseControl()
+    {
+        ControllableEntity* entity = this->controllableEntity_;
+
+        if (!entity)
+            return;
+
+        this->controllableEntity_->getController()->setActive(false);
+        //this->controllableEntity_->getController()->setControllableEntity(NULL);
+        this->controllableEntity_->setController(0);
+    }
+
     void PlayerInfo::stopTemporaryControl()
     {
Index: code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.h
===================================================================
--- code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.h	(revision 8501)
+++ code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.h	(revision 8544)
@@ -68,4 +68,5 @@
             void startControl(ControllableEntity* entity);
             void stopControl();
+            void pauseControl();
             void startTemporaryControl(ControllableEntity* entity);
             void stopTemporaryControl();
