- Timestamp:
- Nov 3, 2015, 5:06:05 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
r10762 r10763 190 190 void CommonController::moveToPosition(const Vector3& target) 191 191 { 192 float factor = 1; 192 193 if (!this->getControllableEntity()) 193 194 return; 194 195 if (this->rank_ == Rank::DIVISIONLEADER) 195 SPEED *= 0.8;196 factor = 0.8; 196 197 if (this->rank_ == Rank::SECTIONLEADER) 197 SPEED *= 0.9;198 factor = 0.9; 198 199 199 200 //100 is (so far) the smallest tolerance (empirically found) that can be reached, … … 233 234 } 234 235 } 235 this->getControllableEntity()->moveFrontBack(1.2f*SPEED); 236 orxout (internal_error) << "MOVING" <<endl ; 237 238 this->getControllableEntity()->moveFrontBack(1.2f*SPEED*factor); 236 239 } 237 240 else … … 257 260 { 258 261 //check pointers 259 if (!this->getControllableEntity() || !this->target_ || !this->target_->getControllableEntity())262 if (!this->getControllableEntity() || !this->target_) 260 263 return false; 261 264 262 265 //check if this points in the direction of target_ 263 266 264 267 Vector3 myPosition = this->getControllableEntity()->getWorldPosition(); 265 Vector3 targetPosition = this->target_->get ControllableEntity()->getWorldPosition();268 Vector3 targetPosition = this->target_->getWorldPosition(); 266 269 Vector3 differenceVector = targetPosition - myPosition; 267 float scalarProduct = differenceVector * WorldEntity::FRONT;270 float scalarProduct = differenceVector.dotProduct(WorldEntity::FRONT); 268 271 Vector3 projection = scalarProduct * WorldEntity::FRONT; 269 272 if ((differenceVector - projection).length() > 50) … … 282 285 allyPosition = it->getControllableEntity()->getWorldPosition(); 283 286 allyDifference = allyPosition - myPosition; 284 allyScalarProduct = allyDifference * WorldEntity::FRONT;287 allyScalarProduct = allyDifference.dotProduct(WorldEntity::FRONT); 285 288 allyProjection = allyScalarProduct * WorldEntity::FRONT; 286 289 if (allyScalarProduct < 0 || allyScalarProduct > scalarProduct) … … 291 294 } 292 295 296 Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity()); 297 if (pawn) 298 pawn->setAimPosition(WorldEntity::FRONT); 299 293 300 return true; 294 301
Note: See TracChangeset
for help on using the changeset viewer.