PlayerControllerComponent.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Scene/Components/SceneComponent.h>
  7. #include <AnKi/Physics/PhysicsPlayerController.h>
  8. namespace anki {
  9. /// @addtogroup scene
  10. /// @{
  11. /// Physics player controller component.
  12. class PlayerControllerComponent : public SceneComponent
  13. {
  14. ANKI_SCENE_COMPONENT(PlayerControllerComponent)
  15. public:
  16. PlayerControllerComponent(SceneNode* node);
  17. void setVelocity(F32 forwardSpeed, F32 jumpSpeed, Vec3 forwardDir, Bool crouch)
  18. {
  19. m_player->updateState(forwardSpeed, forwardDir, jumpSpeed, crouch);
  20. }
  21. void moveToPosition(const Vec3& pos)
  22. {
  23. m_player->moveToPosition(pos);
  24. }
  25. PhysicsPlayerController& getPhysicsPlayerController()
  26. {
  27. return *m_player;
  28. }
  29. private:
  30. PhysicsPlayerControllerPtr m_player;
  31. U32 m_positionVersion = kMaxU32;
  32. void update(SceneComponentUpdateInfo& info, Bool& updated) override;
  33. };
  34. /// @}
  35. } // end namespace anki