- Timestamp:
- May 15, 2010, 6:12:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/rocket/src/modules/weapons/RocketController.cc
r6904 r6905 63 63 { 64 64 haha++; 65 65 66 66 67 SimpleRocket *rocket = static_cast<SimpleRocket*>(this->getControllableEntity()); 68 if (haha<30)rocket->setVelocity(rocket->getVelocity()*1.03); 67 69 if (this->target_) { 68 rocket->rotatePitch(0.5); 69 rocket->rotateYaw(0.5); 70 this->setTargetPosition(); 71 this->moveToTargetPosition(); 72 70 73 } 71 rocket->setVelocity(rocket->getVelocity()*1.03); 74 75 if (haha>500) rocket->setDestroy();; 72 76 73 77 } … … 80 84 } 81 85 86 void RocketController::setTargetPosition() { 87 this->targetPosition_=this->target_->getPosition(); 88 //this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getPosition(), this->target_->getVelocity()); 89 } 90 void RocketController::moveToTargetPosition() { 91 this->moveToPosition(this->targetPosition_); 92 } 82 93 83 void RocketController::setTarget(Pawn* target) { 94 95 96 void RocketController::setTarget(WorldEntity* target) { 84 97 this->target_ = target; 98 COUT(0)<<"got target\n"; 85 99 } 100 101 void RocketController::moveToPosition(const Vector3& target) 102 { 103 if (!this->getControllableEntity()) 104 return; 105 106 COUT(0)<<"moving"; 107 108 Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target); 109 float distance = (target - this->getControllableEntity()->getPosition()).length(); 110 111 if (this->target_ || distance > 10) 112 { 113 // Multiply with 0.8 to make them a bit slower 114 this->getControllableEntity()->rotateYaw(-0.2f * sgn(coord.x) * coord.x*coord.x); 115 this->getControllableEntity()->rotatePitch(0.2f * sgn(coord.y) * coord.y*coord.y); 116 117 } 118 } 86 119 87 120
Note: See TracChangeset
for help on using the changeset viewer.