Fix blackjack hook dialog placement

This commit is contained in:
dldydtn9755-crypto
2026-06-23 12:25:58 +09:00
parent e56809e24b
commit 86e1b4ac24
5 changed files with 62 additions and 3 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9da98374aa5716949a8d2c32ea5967cc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
using UnityEngine;
public class BlackjackDialogHudFix : MonoBehaviour
{
[Header("Anchor")]
public Transform speakerAnchor; // 후크 기준 위치
public Camera targetCamera; // 비워두면 Camera.main 사용
[Header("Panel Check")]
public GameObject dialoguePanel; // DialoguePanel 넣기
public bool onlyWhenPanelActive = true;
[Header("Placement")]
public float chestHeight = 2.0f;
public float forwardOffset = 0.7f;
public float lateralOffset = 0f;
private void LateUpdate()
{
if (speakerAnchor == null)
return;
if (onlyWhenPanelActive && dialoguePanel != null && !dialoguePanel.activeInHierarchy)
return;
Camera cam = targetCamera != null ? targetCamera : Camera.main;
if (cam == null)
return;
Vector3 toCam = cam.transform.position - speakerAnchor.position;
toCam.y = 0f;
if (toCam.sqrMagnitude < 0.0001f)
return;
Vector3 dir = toCam.normalized;
Vector3 right = Vector3.Cross(Vector3.up, dir).normalized;
Vector3 chestWorld = speakerAnchor.position + Vector3.up * chestHeight;
transform.position =
chestWorld +
dir * forwardOffset +
right * lateralOffset;
transform.rotation = Quaternion.LookRotation(-dir);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2b4bf258be179644ca6c223f911e15c7