- Timestamp:
- May 30, 2010, 3:57:05 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/modules/weapons/RocketController.cc
r7018 r7021 50 50 this->rocket_->setController(this); 51 51 this->setControllableEntity(dynamic_cast<ControllableEntity*> (this->rocket_)); 52 this->counter_=0;53 52 } 54 53 … … 62 61 void RocketController::tick(float dt) 63 62 { 64 counter_++;65 63 66 64 if (this->target_ && this->rocket_->hasFuel()) { … … 99 97 if (!this->getControllableEntity()) 100 98 return; 101 Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target); 102 float distance = (target - this->getControllableEntity()->getWorldPosition()).length(); 99 100 Vector2 coord = get2DViewdirection(this->rocket_->getPosition(), this->rocket_->getOrientation() * WorldEntity::FRONT, this->rocket_->getOrientation() * WorldEntity::UP, target); 101 float distance = (target - this->rocket_->getWorldPosition()).length(); 103 102 104 103 105 if (distance > 1000 &&this->getControllableEntity()->getVelocity().squaredLength()<160000)106 this-> getControllableEntity()->setAcceleration(this->rocket_->getOrientation()*Vector3(-20,-20,-20));104 if (distance > 1000 && this->rocket_->getVelocity().squaredLength()<160000) 105 this->rocket_->setAcceleration(this->rocket_->getOrientation()*Vector3(-20,-20,-20)); 107 106 if (distance <1000) this->rocket_->setAcceleration(0,0,0); 108 109 this-> getControllableEntity()->rotateYaw(-sgn(coord.x)*coord.x*coord.x);110 this-> getControllableEntity()->rotatePitch(sgn(coord.y)*coord.y*coord.y);107 108 this->rocket_->rotateYaw(-sgn(coord.x)*coord.x*coord.x); 109 this->rocket_->rotatePitch(sgn(coord.y)*coord.y*coord.y); 111 110 } 112 111
Note: See TracChangeset
for help on using the changeset viewer.