- Timestamp:
- Nov 27, 2015, 1:41:26 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10873 r10875 68 68 if (!this->isActive()) 69 69 return; 70 70 if (this->myLeader_ && this->myLeader_->getAction() != Action::FIGHT && this->myLeader_->getAction() != 71 Action::FIGHTALL && this->myLeader_->getAction() != Action::ATTACK) 72 { 73 ControllableEntity* myEntity = this->getControllableEntity(); 74 Vector3 myPosition = myEntity->getWorldPosition(); 75 if (!this->myLeader_) 76 { 77 return; 78 } 79 ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity(); 80 Quaternion orient = leaderEntity->getWorldOrientation(); 81 Vector3 leaderPosition = leaderEntity->getWorldPosition(); 82 83 Vector3 targetRelativePosition = getFormationPosition(); 84 if (!this->myLeader_) 85 { 86 return; 87 } 88 Vector3 targetAbsolutePosition = 89 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 90 + (orient* (targetRelativePosition))); 91 92 this->setAction (Action::FLY, targetAbsolutePosition, orient); 93 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 94 { 95 this->boostControl(); 96 } 97 else 98 { 99 this->getControllableEntity()->boost(false); 100 } 101 } 71 102 72 103 SUPER(WingmanController, tick, dt); … … 123 154 default: 124 155 { 125 ControllableEntity* myEntity = this->getControllableEntity();126 Vector3 myPosition = myEntity->getWorldPosition();127 if (!this->myLeader_)128 {129 return;130 }131 156 132 ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity();133 Quaternion orient = leaderEntity->getWorldOrientation();134 Vector3 leaderPosition = leaderEntity->getWorldPosition();135 136 Vector3 targetRelativePosition = getFormationPosition();137 if (!this->myLeader_)138 {139 return;140 }141 Vector3 targetAbsolutePosition =142 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)143 + (orient* (targetRelativePosition)));144 145 this->setAction (Action::FLY, targetAbsolutePosition, orient);146 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)147 {148 this->boostControl();149 }150 else151 {152 this->getControllableEntity()->boost(false);153 }154 157 } 155 158 }
Note: See TracChangeset
for help on using the changeset viewer.