Fix: body keeps orientation on target loss, fix close-range selection
PostureComponent: body no longer returns to original yaw when TargetActor is cleared — only head and eyes return to neutral. InteractionComponent: add AgentEyeLevelOffset (default 150cm) so the view cone check targets chest height instead of feet, preventing selection loss at close range. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c6aed472f9
commit
6c081e1207
@ -129,7 +129,7 @@ UPS_AI_ConvAgent_ElevenLabsComponent* UPS_AI_ConvAgent_InteractionComponent::Eva
|
|||||||
AActor* AgentActor = Agent->GetOwner();
|
AActor* AgentActor = Agent->GetOwner();
|
||||||
if (!AgentActor) continue;
|
if (!AgentActor) continue;
|
||||||
|
|
||||||
const FVector AgentLocation = AgentActor->GetActorLocation();
|
const FVector AgentLocation = AgentActor->GetActorLocation() + FVector(0.0f, 0.0f, AgentEyeLevelOffset);
|
||||||
const FVector ToAgent = AgentLocation - ViewLocation;
|
const FVector ToAgent = AgentLocation - ViewLocation;
|
||||||
const float DistSq = ToAgent.SizeSquared();
|
const float DistSq = ToAgent.SizeSquared();
|
||||||
|
|
||||||
|
|||||||
@ -337,15 +337,8 @@ void UPS_AI_ConvAgent_PostureComponent::TickComponent(
|
|||||||
{
|
{
|
||||||
// ── No target: smoothly return to neutral ──────────────────────────
|
// ── No target: smoothly return to neutral ──────────────────────────
|
||||||
|
|
||||||
// Body: return to original facing via sticky target
|
// Body: keep current orientation — don't rotate back to original facing.
|
||||||
TargetBodyWorldYaw = OriginalActorYaw - MeshForwardYawOffset;
|
// The body stays wherever the last tracking left it; only head and eyes reset.
|
||||||
const float NeutralDelta = FMath::FindDeltaAngleDegrees(
|
|
||||||
Owner->GetActorRotation().Yaw, TargetBodyWorldYaw);
|
|
||||||
if (FMath::Abs(NeutralDelta) > 0.1f)
|
|
||||||
{
|
|
||||||
const float NeutralStep = FMath::FInterpTo(0.0f, NeutralDelta, SafeDeltaTime, ReturnToNeutralSpeed);
|
|
||||||
Owner->AddActorWorldRotation(FRotator(0.0f, NeutralStep, 0.0f));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Head + Eyes: return to center
|
// Head + Eyes: return to center
|
||||||
TargetHeadYaw = 0.0f;
|
TargetHeadYaw = 0.0f;
|
||||||
|
|||||||
@ -77,6 +77,14 @@ public:
|
|||||||
ToolTip = "Sticky cone half-angle for the current agent (degrees).\nMust be >= ViewConeHalfAngle for hysteresis to work.\n60 = agent stays selected until 120-degree total cone is exceeded."))
|
ToolTip = "Sticky cone half-angle for the current agent (degrees).\nMust be >= ViewConeHalfAngle for hysteresis to work.\n60 = agent stays selected until 120-degree total cone is exceeded."))
|
||||||
float SelectionStickyAngle = 60.0f;
|
float SelectionStickyAngle = 60.0f;
|
||||||
|
|
||||||
|
/** Height offset (cm) added to the agent's origin for the view cone check.
|
||||||
|
* Agent origins are typically at foot level; this shifts the target point
|
||||||
|
* up to chest/head height so close-range look-at checks don't fail. */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PS AI ConvAgent|Interaction",
|
||||||
|
meta = (ClampMin = "0",
|
||||||
|
ToolTip = "Height offset (cm) above the agent origin for the view cone check.\nPrevents losing selection at close range because the camera looks above the agent's feet.\n150 = roughly chest height for a MetaHuman."))
|
||||||
|
float AgentEyeLevelOffset = 150.0f;
|
||||||
|
|
||||||
/** When false, only distance matters for selection (no view cone check).
|
/** When false, only distance matters for selection (no view cone check).
|
||||||
* The closest agent within MaxInteractionDistance is always selected. */
|
* The closest agent within MaxInteractionDistance is always selected. */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PS AI ConvAgent|Interaction",
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PS AI ConvAgent|Interaction",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user