Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 19, 2005, 4:52:01 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the spaceshipcontroll branche into the trunk
merged with command
svn merge -r6036:HEAD spaceshipcontrol/ ../trunk/
no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/weapons/guided_missile.cc

    r6142 r6162  
    4545  this->energyMin = 1;
    4646  this->energyMax = 10;
    47   this->lifeSpan = 5.0;
    48   this->agility = 5.0;
    49   this->maxVelocity = 100;
     47  this->lifeSpan = 10.0;
     48  this->agility = 4;
     49  this->maxVelocity = 75;
    5050
    5151  this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5);
     
    147147void GuidedMissile::tick (float time)
    148148{
    149   //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
     149
    150150  if (this->target != NULL && this->target->getParent() != PNode::getNullParent())
    151151   {
    152      velocity += ((target->getAbsCoor() - this->getAbsCoor()).getNormalized())*agility;
    153      float speed = velocity.len();
    154      if (speed > this->maxVelocity)
    155        velocity *= maxVelocity/speed;
     152    speed = velocity.len();
     153    diffVector = ((target->getAbsCoor() - this->getAbsCoor()).getNormalized());
     154
     155    if(velocity.dot(diffVector) != 0)
     156    {
     157     correctionVector = (( ( diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility;
     158
     159      if(velocity.dot(diffVector) > 0)
     160        velocity += correctionVector;
     161      else if (velocity.dot(diffVector) < 0)
     162        velocity -= correctionVector;
     163    }
     164    else
     165      velocity += diffVector * agility;
    156166
    157167     this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)));
    158168   }
     169
     170  velocity *= maxVelocity/velocity.len();
    159171  Vector v = this->velocity * (time);
    160172  this->shiftCoor(v);
Note: See TracChangeset for help on using the changeset viewer.