Added rotation field to player and pass them to jolt

This commit is contained in:
Antoine Pilote
2023-07-09 21:40:00 -04:00
parent 49592bbbbb
commit 1049333cfa
2 changed files with 6 additions and 5 deletions

View File

@@ -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<PhysicShape> Shape;
//bool m_onJumpableGround; // A bit lower contact than just onGround
float m_bottomYOffset;
float m_bottomRoundedRegionYOffset;

View File

@@ -286,10 +286,12 @@ namespace Nuake
const auto& capsuleColliderComponent = entity.GetComponent<CapsuleColliderComponent>();
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<Physics::CharacterController>(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);