Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 3, 2015, 5:06:05 PM (8 years ago)
Author:
gania
Message:

fixed a bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc

    r10762 r10763  
    190190    void CommonController::moveToPosition(const Vector3& target)
    191191    {
     192        float factor = 1;
    192193        if (!this->getControllableEntity())
    193194            return;
    194195        if (this->rank_ == Rank::DIVISIONLEADER)
    195             SPEED *= 0.8;
     196            factor = 0.8;
    196197        if (this->rank_ == Rank::SECTIONLEADER)
    197             SPEED *= 0.9;
     198            factor = 0.9;
    198199       
    199200        //100 is (so far) the smallest tolerance (empirically found) that can be reached,
     
    233234                }
    234235            }
    235             this->getControllableEntity()->moveFrontBack(1.2f*SPEED);
     236                    orxout (internal_error) << "MOVING" <<endl ;
     237
     238            this->getControllableEntity()->moveFrontBack(1.2f*SPEED*factor);
    236239        }
    237240        else
     
    257260    {
    258261        //check pointers
    259         if (!this->getControllableEntity() || !this->target_ || !this->target_->getControllableEntity())
     262        if (!this->getControllableEntity() || !this->target_)
    260263            return false;
    261        
     264
    262265        //check if this points in the direction of target_
    263266
    264267        Vector3 myPosition = this->getControllableEntity()->getWorldPosition();
    265         Vector3 targetPosition = this->target_->getControllableEntity()->getWorldPosition();
     268        Vector3 targetPosition = this->target_->getWorldPosition();
    266269        Vector3 differenceVector = targetPosition - myPosition;
    267         float scalarProduct = differenceVector * WorldEntity::FRONT;
     270        float scalarProduct = differenceVector.dotProduct(WorldEntity::FRONT);
    268271        Vector3 projection = scalarProduct * WorldEntity::FRONT;
    269272        if ((differenceVector - projection).length() > 50)
     
    282285                allyPosition = it->getControllableEntity()->getWorldPosition();
    283286                allyDifference = allyPosition - myPosition;
    284                 allyScalarProduct = allyDifference * WorldEntity::FRONT;
     287                allyScalarProduct = allyDifference.dotProduct(WorldEntity::FRONT);
    285288                allyProjection = allyScalarProduct * WorldEntity::FRONT;
    286289                if (allyScalarProduct < 0 || allyScalarProduct > scalarProduct)
     
    291294        }
    292295
     296        Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
     297        if (pawn)
     298            pawn->setAimPosition(WorldEntity::FRONT);
     299   
    293300        return true;
    294301
Note: See TracChangeset for help on using the changeset viewer.