Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 8, 2008, 5:04:18 PM (16 years ago)
Author:
landauf
Message:
  • added a prediction-crosshair to the navigation focus
  • fixed a bug in SpaceShipAI's target movement prediction - bots are more accurate now
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/SpaceShipAI.cc

    r1564 r1566  
    238238        this->setMovePitch(0.8 * sgn(coord.y));
    239239
    240         if ((this->targetPosition_ - this->getPosition()).length() > 300)
     240        if ((this->targetPosition_ - this->getPosition()).length() > 500)
    241241            this->setMoveLongitudinal(0.8);
    242242
     
    287287            return;
    288288
    289         Vector3 enemymovement = this->target_->getVelocity();
    290         Vector3 distance_normalised = this->target_->getPosition() - this->getPosition();
    291         distance_normalised.normalise();
    292 
    293         float scalarprod = enemymovement.dotProduct(distance_normalised);
    294         float aimoffset = scalarprod*scalarprod + Projectile::getSpeed() * Projectile::getSpeed() - this->target_->getVelocity().squaredLength();
    295 
    296         if (aimoffset < 0)
    297         {
    298             this->bHasTargetPosition_ = false;
    299             return;
    300         }
    301         aimoffset = -scalarprod + sqrt(aimoffset);
    302         this->targetPosition_ = this->getPosition() + enemymovement + distance_normalised * aimoffset;
    303         this->bHasTargetPosition_ = true;
     289        this->targetPosition_ = getPredictedPosition(this->getPosition(), Projectile::getSpeed(), this->target_->getPosition(), this->target_->getOrientation() * this->target_->getVelocity());
     290        this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO);
    304291    }
    305292
Note: See TracChangeset for help on using the changeset viewer.