BsFPSWalker.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include "BsPrerequisites.h"
  3. #include "Scene/BsComponent.h"
  4. #include "Input/BsVirtualInput.h"
  5. namespace bs
  6. {
  7. /**
  8. * Component that controls movement through a character controller, used for first-person movement. The
  9. * CharacterController component must be attached to the same SceneObject this component is on.
  10. */
  11. class FPSWalker : public Component
  12. {
  13. public:
  14. FPSWalker(const HSceneObject& parent);
  15. /** Triggered once per frame. Allows the component to handle input and move. */
  16. void fixedUpdate() override;
  17. private:
  18. HCharacterController mController;
  19. float mCurrentSpeed = 0.0f; /**< Current speed of the camera. */
  20. VirtualButton mMoveForward; /**< Key binding for moving the camera forward. */
  21. VirtualButton mMoveBack; /**< Key binding for moving the camera backward. */
  22. VirtualButton mMoveLeft; /**< Key binding for moving the camera left. */
  23. VirtualButton mMoveRight; /**< Key binding for moving the camera right. */
  24. VirtualButton mFastMove; /**< Key that speeds up movement while held. */
  25. };
  26. using HFPSWalker = GameObjectHandle<FPSWalker>;
  27. }