- Timestamp:
- May 26, 2016, 3:54:24 PM (8 years ago)
- 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 3 3 DebugTask.cc 4 4 stringOutTask.cc 5 MoveToTask.cc 5 6 ) -
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 -
code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.h
r11190 r11204 43 43 virtual ~MoveToTask(){} 44 44 45 void initialize(float startTime, PlayerInfo* player, vector3 destination);45 void initialize(float startTime, PlayerInfo* player, Vector3 destination, float velocity); 46 46 47 47 virtual bool update(float dt) override; … … 60 60 ControllableEntity* entity_; 61 61 62 vector3 destination_;62 Vector3 direction_; 63 63 64 Vector3 destination_; 65 66 // velocitz in m/s 64 67 float velocity_; 65 68
Note: See TracChangeset
for help on using the changeset viewer.