Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6161 in orxonox.OLD for branches/spaceshipcontrol/src/world_entities


Ignore:
Timestamp:
Dec 19, 2005, 12:50:50 PM (19 years ago)
Author:
snellen
Message:

guided_missile.cc in /world_entities/weapons updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/spaceshipcontrol/src/world_entities/weapons/guided_missile.cc

    r6159 r6161  
    156156    speed = velocity.len();
    157157    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;
    159162
    160163      if(velocity.dot(diffVector) > 0)
    161        velocity += (( correctionVector - velocity).getNormalized()) * agility;
     164        velocity += correctionVector;
    162165      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;
    166170
    167171     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.