CharacterTest.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Tests/Character/CharacterBaseTest.h>
  5. #include <Jolt/Physics/Character/Character.h>
  6. // Simple test that test the Character class. Allows the user to move around with the arrow keys and jump with the J button.
  7. class CharacterTest : public CharacterBaseTest
  8. {
  9. public:
  10. JPH_DECLARE_RTTI_VIRTUAL(CharacterTest)
  11. // Destructor
  12. virtual ~CharacterTest() override;
  13. // Initialize the test
  14. virtual void Initialize() override;
  15. // Update the test, called before the physics update
  16. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  17. // Update the test, called after the physics update
  18. virtual void PostPhysicsUpdate(float inDeltaTime) override;
  19. protected:
  20. // Get position of the character
  21. virtual Vec3 GetCharacterPosition() const override { return mCharacter->GetPosition(); }
  22. // Handle user input to the character
  23. virtual void HandleInput(Vec3Arg inMovementDirection, bool inJump, bool inSwitchStance, float inDeltaTime) override;
  24. private:
  25. // The 'player' character
  26. Ref<Character> mCharacter;
  27. };