From 1049333cfaabb2172cb5569471a89daf54e4eec6 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Sun, 9 Jul 2023 21:40:00 -0400 Subject: [PATCH] Added rotation field to player and pass them to jolt --- Nuake/src/Core/Physics/CharacterController.h | 5 ++--- Nuake/src/Scene/Systems/PhysicsSystem.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Nuake/src/Core/Physics/CharacterController.h b/Nuake/src/Core/Physics/CharacterController.h index b76097b9..9e20bb6b 100644 --- a/Nuake/src/Core/Physics/CharacterController.h +++ b/Nuake/src/Core/Physics/CharacterController.h @@ -13,8 +13,9 @@ namespace Nuake class CharacterController { public: - Vector3 Position = Vector3(0, 0, 0); + Quat Rotation = Quat(1, 0, 0, 0); + Entity Owner; bool IsOnGround = false; @@ -25,8 +26,6 @@ namespace Nuake float Friction = 0.5f; Ref Shape; - //bool m_onJumpableGround; // A bit lower contact than just onGround - float m_bottomYOffset; float m_bottomRoundedRegionYOffset; diff --git a/Nuake/src/Scene/Systems/PhysicsSystem.cpp b/Nuake/src/Scene/Systems/PhysicsSystem.cpp index 1a693bc4..b7b94ef5 100644 --- a/Nuake/src/Scene/Systems/PhysicsSystem.cpp +++ b/Nuake/src/Scene/Systems/PhysicsSystem.cpp @@ -286,10 +286,12 @@ namespace Nuake const auto& capsuleColliderComponent = entity.GetComponent(); auto& capsule = capsuleColliderComponent.Capsule; - float friction = characterControllerComponent.Friction; - float maxSlopeAngle = characterControllerComponent.MaxSlopeAngle; + const float friction = characterControllerComponent.Friction; + const float maxSlopeAngle = characterControllerComponent.MaxSlopeAngle; auto characterController = CreateRef(capsule, friction, maxSlopeAngle); characterController->SetEntity(entity); // Used to link back to the entity + characterController->Position = transformComponent.GetGlobalPosition(); + characterController->Rotation = transformComponent.GetGlobalRotation(); characterControllerComponent.CharacterController = characterController; PhysicsManager::Get().RegisterCharacterController(characterControllerComponent.CharacterController);