Index: code/branches/netp3/src/orxonox/objects/worldentities/PongBall.cc
===================================================================
--- code/branches/netp3/src/orxonox/objects/worldentities/PongBall.cc	(revision 3004)
+++ code/branches/netp3/src/orxonox/objects/worldentities/PongBall.cc	(revision 3043)
@@ -32,5 +32,4 @@
 #include "core/CoreIncludes.h"
 #include "core/GameMode.h"
-#include "objects/worldentities/PongBat.h"
 #include "objects/gametypes/Gametype.h"
 
@@ -47,5 +46,16 @@
         this->speed_ = 0;
         this->bat_ = 0;
+        this->batID_ = new unsigned int[2];
+        this->batID_[0] = OBJECTID_UNKNOWN;
+        this->batID_[1] = OBJECTID_UNKNOWN;
         this->relMercyOffset_ = 0.05;
+        
+        this->registerVariables();
+    }
+    
+    void PongBall::registerVariables()
+    {
+        registerVariable( this->batID_[0] );
+        registerVariable( this->batID_[1], variableDirection::toclient, new NetworkCallback<PongBall>( this, &PongBall::applyBats) );
     }
 
@@ -119,4 +129,53 @@
                 this->setPosition(position);
         }
+        else
+        {
+          Vector3 position = this->getPosition();
+          Vector3 velocity = this->getVelocity();
+
+          if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
+          {
+            velocity.z = -velocity.z;
+
+            if (position.z > this->fieldHeight_ / 2)
+              position.z = this->fieldHeight_ / 2;
+            if (position.z < -this->fieldHeight_ / 2)
+              position.z = -this->fieldHeight_ / 2;
+          }
+
+          if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
+          {
+            float distance = 0;
+
+            if (this->bat_)
+            {
+              if (position.x > this->fieldWidth_ / 2 && this->bat_[1])
+              {
+                distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2);
+                if (fabs(distance) <= 1)
+                {
+                  position.x = this->fieldWidth_ / 2;
+                  velocity.x = -velocity.x;
+                  velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
+                }
+              }
+              if (position.x < -this->fieldWidth_ / 2 && this->bat_[0])
+              {
+                distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2);
+                if (fabs(distance) <= 1)
+                {
+                  position.x = -this->fieldWidth_ / 2;
+                  velocity.x = -velocity.x;
+                  velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
+                }
+              }
+            }
+          }
+
+          if (velocity != this->getVelocity())
+            this->setVelocity(velocity);
+          if (position != this->getPosition())
+            this->setPosition(position);
+        }
     }
 
Index: code/branches/netp3/src/orxonox/objects/worldentities/PongBall.h
===================================================================
--- code/branches/netp3/src/orxonox/objects/worldentities/PongBall.h	(revision 3004)
+++ code/branches/netp3/src/orxonox/objects/worldentities/PongBall.h	(revision 3043)
@@ -33,4 +33,5 @@
 
 #include "objects/worldentities/MovableEntity.h"
+#include "objects/worldentities/PongBat.h"
 
 namespace orxonox
@@ -43,4 +44,6 @@
 
             virtual void tick(float dt);
+            
+            void registerVariables();
 
             void setFieldDimension(float width, float height)
@@ -61,5 +64,8 @@
 
             void setBats(PongBat** bats)
-                { this->bat_ = bats; }
+            { this->bat_ = bats; this->batID_[0] = this->bat_[0]->getObjectID(); this->batID_[1] = this->bat_[1]->getObjectID(); }
+            
+            void applyBats()
+            { if(!this->bat_) this->bat_ = new PongBat*[2]; if(this->batID_[0] != OBJECTID_UNKNOWN) this->bat_[0] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[0])); if(this->batID_[1] != OBJECTID_UNKNOWN) this->bat_[1] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[1])); }
 
             static const float MAX_REL_Z_VELOCITY;
@@ -71,4 +77,5 @@
             float batlength_;
             PongBat** bat_;
+            unsigned int* batID_;
             float relMercyOffset_;
     };
