Changeset 6131 in orxonox.OLD for branches/spaceshipcontrol/src/world_entities/weapons
- Timestamp:
- Dec 16, 2005, 4:18:16 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/spaceshipcontrol/src/world_entities/weapons/guided_missile.cc
r6044 r6131 49 49 this->energyMax = 10; 50 50 this->lifeSpan = 5.0; 51 this->agility = 0.1;52 this->maxVelocity = 100;51 this->agility = 50; 52 this->maxVelocity = 300; 53 53 54 54 this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5); … … 150 150 */ 151 151 void GuidedMissile::tick (float time) 152 { 152 { 153 154 153 155 154 156 if (target != NULL && target->getParent() != NullParent::getInstance()) 155 157 { 156 float speed = velocity.len(); 157 158 velocity += (((target->getAbsCoor() - this->getAbsCoor()).getNormalized())*speed - velocity)*agility; 159 velocity *= (velocity.getNormalized())*speed; 160 161 162 velocity *= maxVelocity/speed; 158 float speed = velocity.len(); 159 Vector diffVector = ((target->getAbsCoor() - this->getAbsCoor()).getNormalized()); 160 161 if (velocity.dot(diffVector) != 0) 162 163 if(velocity.dot(diffVector) > 0) 164 velocity += ( ( diffVector * (speed * speed/( velocity.dot(diffVector ) ) ) - velocity).getNormalized()) * agility; 165 else 166 velocity -= ( ( diffVector * (speed * speed/( velocity.dot(diffVector ) ) ) - velocity).getNormalized()) * agility; 167 168 else 169 velocity += diffVector * agility; 163 170 164 171 this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0))); 165 172 } 166 173 174 velocity *= maxVelocity/velocity.len(); 167 175 Vector v = this->velocity * (time); 168 176 this->shiftCoor(v);
Note: See TracChangeset
for help on using the changeset viewer.