Changeset 5765 in orxonox.OLD for branches/guidedmissile/src/world_entities/weapons/guided_missile.cc
- Timestamp:
- Nov 24, 2005, 5:24:39 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/guidedmissile/src/world_entities/weapons/guided_missile.cc
r5764 r5765 29 29 #include "particle_system.h" 30 30 31 32 #include "null_parent.h" 31 33 32 34 using namespace std; … … 49 51 this->lifeSpan = 5; 50 52 this->agility = 5; 53 this->maxVelocity = 100; 51 54 52 55 this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5); … … 150 153 { 151 154 //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1); 152 float speed = velocity.len(); 153 if (target != NULL) 155 if (target != NULL && target->getParent() != NullParent::getInstance()) 154 156 { 155 157 velocity += ((target->getAbsCoor() - this->getAbsCoor()).getNormalized())*agility; 156 velocity *= speed/velocity.len(); 158 float speed = velocity.len(); 159 if (speed > this->maxVelocity) 160 velocity *= maxVelocity/speed; 161 162 this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0))); 157 163 } 158 164 Vector v = this->velocity * (time); … … 172 178 /** 173 179 * the function gets called, when the projectile is destroyed 174 */180 */ 175 181 void GuidedMissile::destroy () 176 182 { … … 200 206 201 207 glPopMatrix(); 202 } 203 208 209 } 210
Note: See TracChangeset
for help on using the changeset viewer.