Changeset 10079 in orxonox.OLD for branches/playability/src/world_entities/projectiles/swarm_projectile.cc
- Timestamp:
- Dec 15, 2006, 8:34:47 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/projectiles/swarm_projectile.cc
r10078 r10079 28 28 29 29 #include "class_id_DEPRECATED.h" 30 31 #include "math/vector.h" 30 32 31 33 ObjectListDefinitionID(SwarmProjectile, CL_SWARM_PROJECTILE); … … 54 56 55 57 this->target = NULL; 56 57 this->rotationSpeed = 100;58 this->angle = 0;59 58 } 60 59 … … 128 127 129 128 this->setHealth(10.0* (float)rand()/(float)RAND_MAX); 129 130 this->maxVelocity = 300; 131 132 this->rotationSpeed = 100; 133 this->angle = 0; 130 134 } 131 135 … … 216 220 this->shiftCoor(v);*/ 217 221 218 float projectileVelocity = this->velocity.len(); 219 if (target != NULL){ 220 float tti; //Time To Impact 221 float targetVelocity = this->target->getVelocity().len(); 222 if (unlikely(projectileVelocity == 0 && targetVelocity == 0)) // TODO calculate this reasonably 223 tti = 1; // we do have a problem.... 224 else 225 tti = this->target->getRelCoor().len() / sqrt ( projectileVelocity * projectileVelocity + targetVelocity * targetVelocity); 226 Vector estTargetDir = (this->target->getRelCoor() + this->target->getVelocity()) * tti; 227 this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time ); 228 } 229 else 230 if (likely(projectileVelocity != 0)) 231 this->velocity *= maxVelocity / projectileVelocity; // set speed to max 232 233 234 this->shiftCoor(velocity * time); 222 // float projectileVelocity = this->getVelocity().len(); 223 // if (target != NULL){ 224 // float tti; //Time To Impact 225 // // float targetVelocity = this->target->getVelocity().len(); 226 // // /* if (unlikely(projectileVelocity == 0 && targetVelocity == 0)) // TODO calculate this reasonably*/ 227 // tti = 1; // we do have a problem.... 228 // // // else 229 // // // tti = (this->getAbsCoor() - this->target->getAbsCoor()).len() / sqrt ( projectileVelocity * projectileVelocity + targetVelocity * targetVelocity); 230 // Vector estTargetDir = this->getAbsCoor() - this->target->getAbsCoor() + this->target->getVelocity() * (0.5); 231 // // this->setVelocity((this->getAbsCoor() - this->target->getAbsCoor()).getNormalized() * this->velocity.len()); 232 // this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time ) * this->maxVelocity; 233 // } 234 // else 235 // if (likely(projectileVelocity != 0)) 236 // this->velocity *= (this->maxVelocity / projectileVelocity); // set speed to max 237 /* 238 Vector v = this->velocity + this->target->getAbsCoor() - this->getAbsCoor(); 239 v.normalize(); 240 v *= projectileVelocity;*/ 241 this->shiftCoor(velocity * (time)); 235 242 236 243 if(this->tickLifeCycle(time))
Note: See TracChangeset
for help on using the changeset viewer.