Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9336 for code/branches


Ignore:
Timestamp:
Jul 29, 2012, 10:44:11 PM (12 years ago)
Author:
landauf
Message:

fixed weird AI movement introduced in waypoints branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2012merge/src/orxonox/controllers/FormationController.cc

    r9272 r9336  
    282282        Vector2 coord = get2DViewcoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
    283283        float distance = (target - this->getControllableEntity()->getPosition()).length();
    284         if(coord.x < 0.0001 && coord.y < 0.0001)
    285         {
    286             // if the ship reaches a direction very close to the direct one, set it to the direct one
    287             Vector3 v_temp = this->getControllableEntity()->getPosition();
    288             Quaternion quat = v_temp.getRotationTo(target);
    289             this->getControllableEntity()->rotate(quat);
    290         }
     284        float rotateX = clamp(coord.x * 10, -1.0f, 1.0f);
     285        float rotateY = clamp(coord.y * 10, -1.0f, 1.0f);
    291286
    292287        if(this->state_ == FREE)
     
    295290            {
    296291                // Multiply with ROTATEFACTOR_FREE to make them a bit slower
    297                 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * coord.x * 2);
    298                 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * coord.y * 2);
     292                this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * rotateX);
     293                this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * rotateY);
    299294            }
    300295
     
    311306            if (this->target_ || distance > 10)
    312307            {
    313                 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * coord.x * 2);
    314                 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * coord.y * 2);
     308                this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * rotateX);
     309                this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * rotateY);
    315310            }
    316311
     
    326321        {
    327322
    328             this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2);
    329             this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2);
     323            this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * rotateX);
     324            this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * rotateY);
    330325
    331326            if (distance < 300)
Note: See TracChangeset for help on using the changeset viewer.