- Timestamp:
- Oct 30, 2015, 11:07:34 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
r10722 r10725 51 51 52 52 RegisterObject(CommonController); 53 54 53 //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&LeaderController::action, this))); 55 54 } … … 60 59 } 61 60 61 void CommonController::moveToPosition(const Vector3& target) 62 { 63 if (!this->getControllableEntity()) 64 return; 65 66 Vector2 coord = get2DViewCoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target); 67 float distance = (target - this->getControllableEntity()->getPosition()).length(); 68 float rotateX = clamp(coord.x * 10, -1.0f, 1.0f); 69 float rotateY = clamp(coord.y * 10, -1.0f, 1.0f); 70 71 72 if (this->target_ || distance > 10) 73 { 74 this->getControllableEntity()->rotateYaw(-1.0f * 0.8f * rotateX); 75 this->getControllableEntity()->rotatePitch(0.8f * rotateY); 76 } 77 78 if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength()) 79 { 80 this->getControllableEntity()->moveFrontBack(-0.05f); // They don't brake with full power to give the player a chance 81 } 82 else if (distance > 100) 83 this->getControllableEntity()->moveFrontBack(0.8f); 84 85 86 87 if (distance < 100) 88 { 89 this->positionReached(); 90 bHasTargetOrientation_=false; 91 } 92 } 62 93 63 94
Note: See TracChangeset
for help on using the changeset viewer.