- Timestamp:
- Dec 19, 2005, 12:50:50 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/spaceshipcontrol/src/world_entities/weapons/guided_missile.cc
r6159 r6161 156 156 speed = velocity.len(); 157 157 diffVector = ((target->getAbsCoor() - this->getAbsCoor()).getNormalized()); 158 correctionVector = ( diffVector * (speed * speed/( velocity.dot(diffVector ) ) )); 158 159 if(velocity.dot(diffVector) != 0) 160 { 161 correctionVector = (( ( diffVector * (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility; 159 162 160 163 if(velocity.dot(diffVector) > 0) 161 velocity += (( correctionVector - velocity).getNormalized()) * agility;164 velocity += correctionVector; 162 165 else if (velocity.dot(diffVector) < 0) 163 velocity -= ( ( correctionVector - velocity).getNormalized()) * agility; 164 else 165 velocity += diffVector * agility; 166 velocity -= correctionVector; 167 } 168 else 169 velocity += diffVector * agility; 166 170 167 171 this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)));
Note: See TracChangeset
for help on using the changeset viewer.