Changeset 10038 in orxonox.OLD for branches/playability/src/world_entities/projectiles
- Timestamp:
- Dec 10, 2006, 11:49:38 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/projectiles/swarm_projectile.cc
r10037 r10038 156 156 Vector SwarmProjectile::newDirection(Vector curDirection, Vector estTargetDir, float angle) 157 157 { 158 if (unlikely(curDirection.len() == 0)) 159 return curDirection; 158 160 printf("recalculating direction\n"); 159 161 float tmp = angleDeg ( curDirection, estTargetDir); … … 209 211 this->shiftCoor(v);*/ 210 212 213 float projectileVelocity = this->velocity.len(); 211 214 if (target != NULL){ 212 float tti = this->target->getRelCoor().len() / this->getVelocity().len(); 215 float tti; //Time To Impact 216 float targetVelocity = this->target->getVelocity().len(); 217 if (unlikely(projectileVelocity == 0 && targetVelocity == 0)) // TODO calculate this reasonably 218 tti = 1; // we do have a problem.... 219 else 220 tti = this->target->getRelCoor().len() / sqrt ( projectileVelocity * projectileVelocity + targetVelocity * targetVelocity); 213 221 Vector estTargetDir = (this->target->getRelCoor() + this->target->getVelocity()) * tti; 214 222 this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time ); 215 223 } 216 224 else 217 velocity *= maxVelocity / velocity.len(); // set speed to max 225 if (likely(projectileVelocity != 0)) 226 this->velocity *= maxVelocity / projectileVelocity; // set speed to max 218 227 219 228
Note: See TracChangeset
for help on using the changeset viewer.