fix: reverse bounce paths (#1798)

This commit is contained in:
David Markowitz 2025-05-18 19:48:40 -07:00 committed by GitHub
parent 891b176b4f
commit 32487dcd5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -54,6 +54,7 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) :
m_SourcePosition = m_Parent->GetPosition(); m_SourcePosition = m_Parent->GetPosition();
m_Paused = false; m_Paused = false;
m_SavedVelocity = NiPoint3Constant::ZERO; m_SavedVelocity = NiPoint3Constant::ZERO;
m_IsBounced = false;
if (!m_Parent->GetComponent<BaseCombatAIComponent>()) SetPath(m_Parent->GetVarAsString(u"attached_path")); if (!m_Parent->GetComponent<BaseCombatAIComponent>()) SetPath(m_Parent->GetVarAsString(u"attached_path"));
} }
@ -158,8 +159,9 @@ void MovementAIComponent::Update(const float deltaTime) {
if (m_Path->pathBehavior == PathBehavior::Loop) { if (m_Path->pathBehavior == PathBehavior::Loop) {
SetPath(m_Path->pathWaypoints); SetPath(m_Path->pathWaypoints);
} else if (m_Path->pathBehavior == PathBehavior::Bounce) { } else if (m_Path->pathBehavior == PathBehavior::Bounce) {
m_IsBounced = !m_IsBounced;
std::vector<PathWaypoint> waypoints = m_Path->pathWaypoints; std::vector<PathWaypoint> waypoints = m_Path->pathWaypoints;
std::reverse(waypoints.begin(), waypoints.end()); if (m_IsBounced) std::reverse(waypoints.begin(), waypoints.end());
SetPath(waypoints); SetPath(waypoints);
} else if (m_Path->pathBehavior == PathBehavior::Once) { } else if (m_Path->pathBehavior == PathBehavior::Once) {
Stop(); Stop();

View File

@ -321,6 +321,8 @@ private:
bool m_Paused; bool m_Paused;
NiPoint3 m_SavedVelocity; NiPoint3 m_SavedVelocity;
bool m_IsBounced{};
}; };
#endif // MOVEMENTAICOMPONENT_H #endif // MOVEMENTAICOMPONENT_H