diff --git a/dGame/dComponents/MovementAIComponent.cpp b/dGame/dComponents/MovementAIComponent.cpp index efe711b3..9463e7d6 100644 --- a/dGame/dComponents/MovementAIComponent.cpp +++ b/dGame/dComponents/MovementAIComponent.cpp @@ -54,6 +54,7 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) : m_SourcePosition = m_Parent->GetPosition(); m_Paused = false; m_SavedVelocity = NiPoint3Constant::ZERO; + m_IsBounced = false; if (!m_Parent->GetComponent()) SetPath(m_Parent->GetVarAsString(u"attached_path")); } @@ -158,8 +159,9 @@ void MovementAIComponent::Update(const float deltaTime) { if (m_Path->pathBehavior == PathBehavior::Loop) { SetPath(m_Path->pathWaypoints); } else if (m_Path->pathBehavior == PathBehavior::Bounce) { + m_IsBounced = !m_IsBounced; std::vector waypoints = m_Path->pathWaypoints; - std::reverse(waypoints.begin(), waypoints.end()); + if (m_IsBounced) std::reverse(waypoints.begin(), waypoints.end()); SetPath(waypoints); } else if (m_Path->pathBehavior == PathBehavior::Once) { Stop(); diff --git a/dGame/dComponents/MovementAIComponent.h b/dGame/dComponents/MovementAIComponent.h index 15b5aaed..dbb0661c 100644 --- a/dGame/dComponents/MovementAIComponent.h +++ b/dGame/dComponents/MovementAIComponent.h @@ -321,6 +321,8 @@ private: bool m_Paused; NiPoint3 m_SavedVelocity; + + bool m_IsBounced{}; }; #endif // MOVEMENTAICOMPONENT_H