1
This commit is contained in:
parent
a8e99b62d5
commit
2b3dcd723e
@ -44,7 +44,9 @@ bool Movement::UpdatePosition()
|
||||
});
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
curr_point.tar_pos.SetY(curr_point.curr_pos.GetY());
|
||||
#endif
|
||||
owner_->SetPos(curr_point.tar_pos);
|
||||
++path_index_;
|
||||
if (path_index_ < paths_.size()) {
|
||||
@ -245,5 +247,22 @@ bool Movement::FindPath(const glm::vec3& target_pos, float distance)
|
||||
owner_->SetAttackDir(paths_.at(0).dir);
|
||||
}
|
||||
}
|
||||
AdjustLastPath(distance);
|
||||
return !paths_.empty();
|
||||
}
|
||||
|
||||
void Movement::AdjustLastPath(float distance)
|
||||
{
|
||||
if (paths_.empty()) {
|
||||
return;
|
||||
}
|
||||
if (distance < 0.01f) {
|
||||
return;
|
||||
}
|
||||
MovePathPoint& point = paths_.at(paths_.size() - 1);
|
||||
if (point.distance + 3 < distance) {
|
||||
return;
|
||||
}
|
||||
point.distance -= distance;
|
||||
point.tar_pos.FromGlmVec3(point.src_pos.ToGlmVec3() + point.dir * point.distance);
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ class Movement
|
||||
bool IsFindPath() { return is_find_path_; }
|
||||
bool FindPath(const glm::vec3& target_pos, float distance);
|
||||
|
||||
private:
|
||||
void AdjustLastPath(float distance);
|
||||
|
||||
private:
|
||||
std::vector<MovePathPoint> paths_;
|
||||
int path_index_ = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user