Compare commits
2 Commits
4d2186c43c
...
662184001d
| Author | SHA1 | Date | |
|---|---|---|---|
| 662184001d | |||
| 163092858c |
Binary file not shown.
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include UE_INLINE_GENERATED_CPP_BY_NAME(PHYSLSMovementBridgeComponent)
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(PHYSLSMovementBridgeComponent)
|
||||||
|
|
||||||
|
#include "Characters/PHYCharacterBase.h"
|
||||||
#include "Characters/PHYCharacterSettings.h"
|
#include "Characters/PHYCharacterSettings.h"
|
||||||
#include "Components/SLSCharacterMovementComponent.h"
|
#include "Components/SLSCharacterMovementComponent.h"
|
||||||
#include "GameFramework/Character.h"
|
#include "GameFramework/Character.h"
|
||||||
@@ -61,3 +62,46 @@ bool UPHYSLSMovementBridgeComponent::InitializeSLSMovementBridge(ACharacter* InC
|
|||||||
bInitialized = true;
|
bInitialized = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UPHYSLSMovementBridgeComponent::HandleMoveInput(const FVector2D MoveInput)
|
||||||
|
{
|
||||||
|
if (!EnsureSLSMovementBridgeReady())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FRotator YawRotation(0.0f, OwnerCharacter->GetControlRotation().Yaw, 0.0f);
|
||||||
|
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
|
||||||
|
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
|
||||||
|
const FVector WorldIntent = (ForwardDirection * MoveInput.Y) + (RightDirection * MoveInput.X);
|
||||||
|
|
||||||
|
if (APHYCharacterBase* PHYCharacter = Cast<APHYCharacterBase>(OwnerCharacter))
|
||||||
|
{
|
||||||
|
PHYCharacter->SetMovementIntent(WorldIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
SLSCharacterMovementComponent->Input_OnMove(MoveInput);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UPHYSLSMovementBridgeComponent::HandleLookInput(const FVector2D LookInput)
|
||||||
|
{
|
||||||
|
if (!EnsureSLSMovementBridgeReady())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SLSCharacterMovementComponent->Input_OnLook(LookInput);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UPHYSLSMovementBridgeComponent::EnsureSLSMovementBridgeReady()
|
||||||
|
{
|
||||||
|
if (bInitialized && OwnerCharacter && SLSCharacterMovementComponent)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ACharacter* Character = OwnerCharacter ? OwnerCharacter.Get() : Cast<ACharacter>(GetOwner());
|
||||||
|
return InitializeSLSMovementBridge(Character, GenericIntegrationComponent, SLSIntegrationComponent);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
||||||
|
|
||||||
#include "Player/PHYPlayerCameraManager.h"
|
|
||||||
|
|
||||||
#include UE_INLINE_GENERATED_CPP_BY_NAME(PHYPlayerCameraManager)
|
|
||||||
|
|
||||||
#include "Player/PHYPlayerController.h"
|
|
||||||
|
|
||||||
FRotator APHYPlayerCameraManager::GetRotationInput_Implementation() const
|
|
||||||
{
|
|
||||||
const APHYPlayerController* PHYController = Cast<APHYPlayerController>(PCOwner);
|
|
||||||
return PHYController ? PHYController->GetCachedRotationInput() : FRotator::ZeroRotator;
|
|
||||||
}
|
|
||||||
|
|
||||||
FVector APHYPlayerCameraManager::GetMovementControlInput_Implementation() const
|
|
||||||
{
|
|
||||||
const APHYPlayerController* PHYController = Cast<APHYPlayerController>(PCOwner);
|
|
||||||
return PHYController ? PHYController->GetCachedMovementControlInput() : FVector::ZeroVector;
|
|
||||||
}
|
|
||||||
@@ -5,9 +5,10 @@
|
|||||||
#include UE_INLINE_GENERATED_CPP_BY_NAME(PHYPlayerController)
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(PHYPlayerController)
|
||||||
|
|
||||||
#include "Characters/PHYPlayerCharacter.h"
|
#include "Characters/PHYPlayerCharacter.h"
|
||||||
|
#include "Characters/PHYCharacterSettings.h"
|
||||||
#include "GIPS_InputSystemComponent.h"
|
#include "GIPS_InputSystemComponent.h"
|
||||||
#include "InputActionValue.h"
|
#include "InputActionValue.h"
|
||||||
#include "Player/PHYPlayerCameraManager.h"
|
#include "Locomotion/PHYSLSMovementBridgeComponent.h"
|
||||||
#include "PHYGameplayTags.h"
|
#include "PHYGameplayTags.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -40,7 +41,14 @@ namespace
|
|||||||
APHYPlayerController::APHYPlayerController(const FObjectInitializer& ObjectInitializer)
|
APHYPlayerController::APHYPlayerController(const FObjectInitializer& ObjectInitializer)
|
||||||
: Super(ObjectInitializer)
|
: Super(ObjectInitializer)
|
||||||
{
|
{
|
||||||
PlayerCameraManagerClass = APHYPlayerCameraManager::StaticClass();
|
const UPHYCharacterSettings* CharacterSettings = GetDefault<UPHYCharacterSettings>();
|
||||||
|
if (CharacterSettings && !CharacterSettings->DefaultPlayerCameraManagerClass.IsNull())
|
||||||
|
{
|
||||||
|
if (UClass* CameraManagerClass = CharacterSettings->DefaultPlayerCameraManagerClass.LoadSynchronous())
|
||||||
|
{
|
||||||
|
PlayerCameraManagerClass = CameraManagerClass;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void APHYPlayerController::BeginPlay()
|
void APHYPlayerController::BeginPlay()
|
||||||
@@ -148,21 +156,8 @@ bool APHYPlayerController::HandleMoveInput(const FInputActionInstance& ActionDat
|
|||||||
|
|
||||||
CachedMovementInput = IsInputReleased(TriggerEvent) ? FVector2D::ZeroVector : ExtractAxis2D(ActionData.GetValue());
|
CachedMovementInput = IsInputReleased(TriggerEvent) ? FVector2D::ZeroVector : ExtractAxis2D(ActionData.GetValue());
|
||||||
|
|
||||||
const FRotator CurrentControlRotation = GetControlRotation();
|
UPHYSLSMovementBridgeComponent* SLSMovementBridge = PHYCharacter->GetSLSMovementBridgeComponent();
|
||||||
const FRotator YawRotation(0.0f, CurrentControlRotation.Yaw, 0.0f);
|
return SLSMovementBridge ? SLSMovementBridge->HandleMoveInput(CachedMovementInput) : false;
|
||||||
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
|
|
||||||
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
|
|
||||||
|
|
||||||
const FVector WorldIntent = (ForwardDirection * CachedMovementInput.Y) + (RightDirection * CachedMovementInput.X);
|
|
||||||
PHYCharacter->SetMovementIntent(WorldIntent);
|
|
||||||
|
|
||||||
if (!CachedMovementInput.IsNearlyZero())
|
|
||||||
{
|
|
||||||
PHYCharacter->AddMovementInput(ForwardDirection, CachedMovementInput.Y);
|
|
||||||
PHYCharacter->AddMovementInput(RightDirection, CachedMovementInput.X);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APHYPlayerController::ConsumeMoveProcessorGuard(const ETriggerEvent TriggerEvent)
|
bool APHYPlayerController::ConsumeMoveProcessorGuard(const ETriggerEvent TriggerEvent)
|
||||||
@@ -198,11 +193,12 @@ bool APHYPlayerController::HandleLookInput(const FInputActionInstance& ActionDat
|
|||||||
CachedLookInput = IsInputReleased(TriggerEvent) ? FVector2D::ZeroVector : ExtractAxis2D(ActionData.GetValue());
|
CachedLookInput = IsInputReleased(TriggerEvent) ? FVector2D::ZeroVector : ExtractAxis2D(ActionData.GetValue());
|
||||||
CachedRotationInput = FRotator(CachedLookInput.Y, CachedLookInput.X, 0.0f);
|
CachedRotationInput = FRotator(CachedLookInput.Y, CachedLookInput.X, 0.0f);
|
||||||
|
|
||||||
if (!CachedLookInput.IsNearlyZero())
|
APHYPlayerCharacter* PHYCharacter = GetPHYPlayerCharacter();
|
||||||
|
if (!PHYCharacter)
|
||||||
{
|
{
|
||||||
AddYawInput(CachedLookInput.X);
|
return false;
|
||||||
AddPitchInput(CachedLookInput.Y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
UPHYSLSMovementBridgeComponent* SLSMovementBridge = PHYCharacter->GetSLSMovementBridgeComponent();
|
||||||
|
return SLSMovementBridge ? SLSMovementBridge->HandleLookInput(CachedLookInput) : false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
class APHYAICharacter;
|
class APHYAICharacter;
|
||||||
class APHYAIController;
|
class APHYAIController;
|
||||||
class APHYPlayerCameraManager;
|
|
||||||
class APHYPlayerCharacter;
|
class APHYPlayerCharacter;
|
||||||
class APHYPlayerController;
|
class APHYPlayerController;
|
||||||
|
class APlayerCameraManager;
|
||||||
class UUGC_CameraDataAssetBase;
|
class UUGC_CameraDataAssetBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +75,7 @@ public:
|
|||||||
|
|
||||||
/** @brief 玩家相机管理器默认软类引用。 */
|
/** @brief 玩家相机管理器默认软类引用。 */
|
||||||
UPROPERTY(Config, EditDefaultsOnly, Category="PHY|Character")
|
UPROPERTY(Config, EditDefaultsOnly, Category="PHY|Character")
|
||||||
TSoftClassPtr<APHYPlayerCameraManager> DefaultPlayerCameraManagerClass;
|
TSoftClassPtr<APlayerCameraManager> DefaultPlayerCameraManagerClass;
|
||||||
|
|
||||||
/** @brief UGC 默认 CameraData 软引用,首期不强制制作资产。 */
|
/** @brief UGC 默认 CameraData 软引用,首期不强制制作资产。 */
|
||||||
UPROPERTY(Config, EditDefaultsOnly, Category="PHY|Character")
|
UPROPERTY(Config, EditDefaultsOnly, Category="PHY|Character")
|
||||||
|
|||||||
@@ -35,6 +35,22 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category="PHY|Locomotion|SLS")
|
UFUNCTION(BlueprintCallable, Category="PHY|Locomotion|SLS")
|
||||||
bool InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent, USLSIntegrationComponent* InSLSIntegrationComponent = nullptr);
|
bool InitializeSLSMovementBridge(ACharacter* InCharacter, UActorComponent* InGenericIntegrationComponent, USLSIntegrationComponent* InSLSIntegrationComponent = nullptr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 通过 SLS 原生移动输入接口处理二维移动输入。
|
||||||
|
* @param MoveInput X 为右移输入,Y 为前进输入。
|
||||||
|
* @return 成功路由到 SLS 运动组件时返回 true。
|
||||||
|
*/
|
||||||
|
UFUNCTION(BlueprintCallable, Category="PHY|Locomotion|SLS|Input")
|
||||||
|
bool HandleMoveInput(FVector2D MoveInput);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 通过 SLS 原生视角输入接口处理二维视角输入。
|
||||||
|
* @param LookInput X 为 Yaw 输入,Y 为 Pitch 输入。
|
||||||
|
* @return 成功路由到 SLS 运动组件时返回 true。
|
||||||
|
*/
|
||||||
|
UFUNCTION(BlueprintCallable, Category="PHY|Locomotion|SLS|Input")
|
||||||
|
bool HandleLookInput(FVector2D LookInput);
|
||||||
|
|
||||||
/** @brief 获取桥接到的角色。 */
|
/** @brief 获取桥接到的角色。 */
|
||||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Locomotion|SLS")
|
||||||
ACharacter* GetOwnerCharacter() const { return OwnerCharacter; }
|
ACharacter* GetOwnerCharacter() const { return OwnerCharacter; }
|
||||||
@@ -56,6 +72,9 @@ public:
|
|||||||
bool IsSLSMovementBridgeInitialized() const { return bInitialized; }
|
bool IsSLSMovementBridgeInitialized() const { return bInitialized; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/** @brief 确保桥接组件已经缓存角色和 SLS 运动组件。 */
|
||||||
|
bool EnsureSLSMovementBridgeReady();
|
||||||
|
|
||||||
/** @brief 拥有 SLS 运动能力的角色。 */
|
/** @brief 拥有 SLS 运动能力的角色。 */
|
||||||
UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS")
|
UPROPERTY(Transient, BlueprintReadOnly, Category="PHY|Locomotion|SLS")
|
||||||
TObjectPtr<ACharacter> OwnerCharacter;
|
TObjectPtr<ACharacter> OwnerCharacter;
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "Camera/UGC_PlayerCameraManager.h"
|
|
||||||
#include "PHYPlayerCameraManager.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief PHY 玩家相机管理器。
|
|
||||||
*
|
|
||||||
* 该类型从 PlayerController 的 C++ 缓存读取输入,不把 UGC 蓝图 Pawn Interface 作为主路径。
|
|
||||||
*/
|
|
||||||
UCLASS(BlueprintType, Blueprintable)
|
|
||||||
class PHY_API APHYPlayerCameraManager : public AUGC_PlayerCameraManager
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
/** @brief 返回玩家视角输入。 */
|
|
||||||
virtual FRotator GetRotationInput_Implementation() const override;
|
|
||||||
|
|
||||||
/** @brief 返回玩家移动控制输入。 */
|
|
||||||
virtual FVector GetMovementControlInput_Implementation() const override;
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user