Changeset 6162 in orxonox.OLD for trunk/src/world_entities/weapons/guided_missile.cc
- Timestamp:
- Dec 19, 2005, 4:52:01 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/guided_missile.cc
r6142 r6162 45 45 this->energyMin = 1; 46 46 this->energyMax = 10; 47 this->lifeSpan = 5.0;48 this->agility = 5.0;49 this->maxVelocity = 100;47 this->lifeSpan = 10.0; 48 this->agility = 4; 49 this->maxVelocity = 75; 50 50 51 51 this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5); … … 147 147 void GuidedMissile::tick (float time) 148 148 { 149 //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1); 149 150 150 if (this->target != NULL && this->target->getParent() != PNode::getNullParent()) 151 151 { 152 velocity += ((target->getAbsCoor() - this->getAbsCoor()).getNormalized())*agility; 153 float speed = velocity.len(); 154 if (speed > this->maxVelocity) 155 velocity *= maxVelocity/speed; 152 speed = velocity.len(); 153 diffVector = ((target->getAbsCoor() - this->getAbsCoor()).getNormalized()); 154 155 if(velocity.dot(diffVector) != 0) 156 { 157 correctionVector = (( ( diffVector * (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility; 158 159 if(velocity.dot(diffVector) > 0) 160 velocity += correctionVector; 161 else if (velocity.dot(diffVector) < 0) 162 velocity -= correctionVector; 163 } 164 else 165 velocity += diffVector * agility; 156 166 157 167 this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0))); 158 168 } 169 170 velocity *= maxVelocity/velocity.len(); 159 171 Vector v = this->velocity * (time); 160 172 this->shiftCoor(v);
Note: See TracChangeset
for help on using the changeset viewer.