Mover.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include <Urho3D/Scene/LogicComponent.h>
  5. using namespace Urho3D;
  6. /// Custom logic component for moving the animated model and rotating at area edges.
  7. class Mover : public LogicComponent
  8. {
  9. URHO3D_OBJECT(Mover, LogicComponent);
  10. public:
  11. /// Construct.
  12. explicit Mover(Context* context);
  13. /// Set motion parameters: forward movement speed, rotation speed, and movement boundaries.
  14. void SetParameters(float moveSpeed, float rotationSpeed, const BoundingBox& bounds);
  15. /// Handle scene update. Called by LogicComponent base class.
  16. void Update(float timeStep) override;
  17. /// Return forward movement speed.
  18. float GetMoveSpeed() const { return moveSpeed_; }
  19. /// Return rotation speed.
  20. float GetRotationSpeed() const { return rotationSpeed_; }
  21. /// Return movement boundaries.
  22. const BoundingBox& GetBounds() const { return bounds_; }
  23. private:
  24. /// Forward movement speed.
  25. float moveSpeed_;
  26. /// Rotation speed.
  27. float rotationSpeed_;
  28. /// Movement boundaries.
  29. BoundingBox bounds_;
  30. };