Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2016, 3:54:24 PM (9 years ago)
Author:
plehmann
Message:

implemented the update function of MoveToTask. but it does not yet work right. it might be more a problem of the controllerDirector than the task.

Location:
code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/CMakeLists.txt

    r11183 r11204  
    33  DebugTask.cc
    44  stringOutTask.cc
     5  MoveToTask.cc
    56)
  • code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.cc

    r11190 r11204  
    2323 *      Paul Lehmann
    2424 *   Co-authors:
    25  *      ...
     25 *      ..
    2626 *
    2727 */
     
    4545    void MoveToTask::initialize(float startTime, PlayerInfo* player, Vector3 destination, float velocity)
    4646    {
    47         this->starTime_ = startTime;
     47        this->startTime_ = startTime;
    4848        this->player_ = player;
    4949        this->entity_ = this->player_->getControllableEntity();
    5050        this->destination_ = destination;
    5151        this->velocity_ = velocity;
    52         this->entity->setVelocity( Vector3(0,0,0) )
     52        this->entity_->setVelocity( Vector3(0,0,0) );
     53        // unit vector in the direction of travel
     54        this->direction_ = (destination - this->entity_->getPosition() )/( (destination - this->entity_->getPosition() ).length() );
     55
    5356    }
    5457
     
    5659    {
    5760
    58         float dl = this->velocity_ * dt;
     61        /* Look at the specified position */
     62        this->entity_->lookAt(this->destination_); 
    5963
    60        
    61         /* Set the position to the correct place in the trajectory */
    62         this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1);
     64        this->entity_->setPosition(this->entity_->getPosition() + velocity_ * dt * direction_);
    6365
    64         /* Look at the specified position */
    65         this->entity_->lookAt(this->currentEvent.v2);
     66        //this->entity_->setVelocity( Vector3(0,0,0) );
    6667
     68        orxout() << (this->entity_->getPosition() - destination_ ).length() << endl;
     69
     70        if ((this->entity_->getPosition() - destination_ ).length() > 30)
     71        {
     72            return true;
     73        }
     74        else
     75        {
     76            return false;
     77        }
    6778    }
    6879
  • code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.h

    r11190 r11204  
    4343            virtual ~MoveToTask(){}
    4444
    45             void initialize(float startTime, PlayerInfo* player, vector3 destination);
     45            void initialize(float startTime, PlayerInfo* player, Vector3 destination, float velocity);
    4646
    4747            virtual bool update(float dt) override;
     
    6060            ControllableEntity* entity_;
    6161
    62             vector3 destination_;
     62            Vector3 direction_;
    6363
     64            Vector3 destination_;
     65
     66            // velocitz in m/s
    6467            float velocity_;
    6568
Note: See TracChangeset for help on using the changeset viewer.