Просмотр исходного кода

CharacterController_FixUpDirection (#18953)

* CharacterController_FixUpDirection

Signed-off-by: Anatoliy <[email protected]>

* Removed [[maybe_unused]] and added AZ_Error

Signed-off-by: Anatoliy <[email protected]>

---------

Signed-off-by: Anatoliy <[email protected]>
Anatoliy 2 месяцев назад
Родитель
Сommit
d236bad5b9

+ 10 - 4
Gems/PhysX/Core/Code/Source/PhysXCharacters/API/CharacterController.cpp

@@ -500,10 +500,16 @@ namespace PhysX
         return PxMathConvert(m_pxController->getUpDirection());
     }
 
-    void CharacterController::SetUpDirection([[maybe_unused]] const AZ::Vector3& upDirection)
-    {
-        AZ_Warning("PhysX Character Controller", false, "Setting up direction is not currently supported.");
-        return;
+    void CharacterController::SetUpDirection(const AZ::Vector3& upDirection)
+    {   
+        if (!m_pxController)
+        {
+            AZ_Error("PhysX Character Controller", false, "Invalid character controller.");
+            return;
+        }
+
+        PHYSX_SCENE_READ_LOCK(m_pxController->getScene());
+        m_pxController->setUpDirection(PxMathConvert(upDirection));
     }
 
     float CharacterController::GetSlopeLimitDegrees() const

+ 5 - 2
Gems/PhysX/Core/Code/Source/PhysXCharacters/Components/CharacterControllerComponent.cpp

@@ -176,9 +176,12 @@ namespace PhysX
         return AZ::Vector3::CreateZero();
     }
 
-    void CharacterControllerComponent::SetUpDirection([[maybe_unused]] const AZ::Vector3& upDirection)
+    void CharacterControllerComponent::SetUpDirection(const AZ::Vector3& upDirection)
     {
-        AZ_Warning("PhysX Character Controller Component", false, "Setting up direction is not currently supported.");
+        if (auto* controller = GetController())
+        {
+            controller->SetUpDirection(upDirection);
+        }
     }
 
     float CharacterControllerComponent::GetSlopeLimitDegrees() const