Changeset 1566 for code/trunk/src/orxonox/objects/SpaceShipAI.cc
- Timestamp:
- Jun 8, 2008, 5:04:18 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/SpaceShipAI.cc
r1564 r1566 238 238 this->setMovePitch(0.8 * sgn(coord.y)); 239 239 240 if ((this->targetPosition_ - this->getPosition()).length() > 300)240 if ((this->targetPosition_ - this->getPosition()).length() > 500) 241 241 this->setMoveLongitudinal(0.8); 242 242 … … 287 287 return; 288 288 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); 304 291 } 305 292
Note: See TracChangeset
for help on using the changeset viewer.