- Timestamp:
- May 26, 2016, 3:54:24 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.cc
r11190 r11204 23 23 * Paul Lehmann 24 24 * Co-authors: 25 * .. .25 * .. 26 26 * 27 27 */ … … 45 45 void MoveToTask::initialize(float startTime, PlayerInfo* player, Vector3 destination, float velocity) 46 46 { 47 this->star Time_ = startTime;47 this->startTime_ = startTime; 48 48 this->player_ = player; 49 49 this->entity_ = this->player_->getControllableEntity(); 50 50 this->destination_ = destination; 51 51 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 53 56 } 54 57 … … 56 59 { 57 60 58 float dl = this->velocity_ * dt; 61 /* Look at the specified position */ 62 this->entity_->lookAt(this->destination_); 59 63 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_); 63 65 64 /* Look at the specified position */ 65 this->entity_->lookAt(this->currentEvent.v2); 66 //this->entity_->setVelocity( Vector3(0,0,0) ); 66 67 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 } 67 78 } 68 79
Note: See TracChangeset
for help on using the changeset viewer.