From 45cbfe782d6a3468aa75e2bc26b5f208b495f706 Mon Sep 17 00:00:00 2001 From: Ino Date: Mon, 3 Mar 2025 10:55:09 +0900 Subject: [PATCH] =?UTF-8?q?top=20=EC=9D=B4=ED=8E=99=ED=8A=B8=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Script/Character/Actor.cs | 27 +++++++++---------- Assets/Script/Character/Mob/MobActor.cs | 14 +++++----- .../Projectile/Projectile_Homing.cs | 26 +++++++++++------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/Assets/Script/Character/Actor.cs b/Assets/Script/Character/Actor.cs index c8ef8b3b3..38a25f125 100644 --- a/Assets/Script/Character/Actor.cs +++ b/Assets/Script/Character/Actor.cs @@ -29,7 +29,7 @@ public class Actor : MyCoroutine public Animator m_animation; protected ActorStatInfo m_Stat; protected double receiveaccumulateDmg, m_Damage, m_attackCoolTime; // 내가 받은 피해, 내가 준 피해, 공격 쿨타임 - protected Transform tf_HUD_HP, tf_HUD_Dmg; + protected Transform tf_HUD_HP, tf_HUD_Dmg, tf_Top; protected Vector3 ObjSize; [SerializeField] Actor _target; @@ -146,19 +146,10 @@ public class Actor : MyCoroutine maxY = rendererMaxY; } } - maxY = Mathf.Min(0.5f, maxY); - var hud_hp = new GameObject("HUD_HP"); - tf_HUD_HP = hud_hp.transform; - tf_HUD_HP.parent = transform; - tf_HUD_HP.position = Get_position() + Vector3.down * 0.1f; - - // maxY를 기준으로 HUD 위치 조정 - Vector3 headPosition = new Vector3(transform.position.x, maxY, transform.position.z); - var hud_dmg = new GameObject("HUD_Dmg"); - tf_HUD_Dmg = hud_dmg.transform; - tf_HUD_Dmg.parent = transform; - tf_HUD_Dmg.position = headPosition; + Set_TF_HUD("HUD_HP", ref tf_HUD_HP, Get_position() + Vector3.down * 0.1f); + Set_TF_HUD("HUD_Dmg", ref tf_HUD_Dmg, Get_position() + Vector3.up * 0.5f); + Set_TF_HUD("HUD_Top", ref tf_Top, new Vector3(transform.position.x, maxY, transform.position.z)); } protected virtual void Start() @@ -228,6 +219,14 @@ public class Actor : MyCoroutine } } + void Set_TF_HUD(string goname, ref Transform tf, Vector3 pos) + { + var hud = new GameObject(goname); + tf = hud.transform; + tf.parent = transform; + tf.position = pos; + } + public bool isPlaying() { float normalizedTime = m_animation.GetCurrentAnimatorStateInfo(0).normalizedTime; @@ -835,7 +834,7 @@ public class Actor : MyCoroutine { return new Vector3(transform.position.x, transform.position.y + ObjSize.y * 0.5f, transform.position.z); } - public Vector3 Get_Top_postion() { return tf_HUD_Dmg.position; } + public Vector3 Get_Top_postion() { return tf_Top.position; } public Vector3 Get_CenterPositionFoward(float dist = 0.3f) { return Get_Center_position() + transform.forward * dist; } public Vector3 Get_PositionFoward(float dist = 0.3f) { return Get_position() + transform.forward * dist; } public Vector3 Get_PositionBack(float dist = 0.3f) { return Get_position() + -transform.forward * dist; } diff --git a/Assets/Script/Character/Mob/MobActor.cs b/Assets/Script/Character/Mob/MobActor.cs index 68b38fd9f..ec6bfc431 100644 --- a/Assets/Script/Character/Mob/MobActor.cs +++ b/Assets/Script/Character/Mob/MobActor.cs @@ -21,7 +21,6 @@ public class MobActor : Actor protected MonsterTableData m_MonsterTableData; protected Dictionary dic_skill = new Dictionary(); Action m_actDie; - protected MobMark m_MobMark; protected NoSeeLongDMob m_NoSeeLongDMob; bool useMeeleAttackPos; bool isNSLDMob; @@ -557,13 +556,12 @@ public class MobActor : Actor public override int Get_Group() { return m_SpawnerId; } protected override void Set_MobMark(bool active) { - if (m_MobMark == null) - { - - m_MobMark = InGameInfo.Ins.Get_Obj(eObj.MobMark).GetComponent(); - m_MobMark.transform.localScale = Vector3.one * 0.2f; - } - m_MobMark.Set(active, tf_HUD_Dmg); + //if (m_MobMark == null) + //{ + // m_MobMark = InGameInfo.Ins.Get_Obj(eObj.MobMark).GetComponent(); + // m_MobMark.transform.localScale = Vector3.one * 0.2f; + //} + //m_MobMark.Set(active, tf_HUD_Dmg); } public override void Play_Hit() diff --git a/Assets/Script/Character/Projectile/Projectile/Projectile_Homing.cs b/Assets/Script/Character/Projectile/Projectile/Projectile_Homing.cs index 339f92799..dd5878668 100644 --- a/Assets/Script/Character/Projectile/Projectile/Projectile_Homing.cs +++ b/Assets/Script/Character/Projectile/Projectile/Projectile_Homing.cs @@ -1,5 +1,6 @@ using System.Collections; using UnityEngine; +using static UnityEngine.GraphicsBuffer; public class Projectile_Homing : ProjectileBase { @@ -17,21 +18,26 @@ public class Projectile_Homing : ProjectileBase { while (m_ProjecTileData.LifeTime > 0) { - // 목표 방향 계산 - Vector3 direction = (m_ProjecTileData.target.Get_Center_position() - transform.position).normalized; + if (m_ProjecTileData.shooter.isTarget) + { + // 목표 방향 계산 + Vector3 direction = (m_ProjecTileData.target.Get_Center_position() - transform.position).normalized; - // 현재 방향을 목표 방향으로 보간 (유도력 적용) - Vector3 newDirection = Vector3.Lerp(transform.forward, direction, homingStrength * Time.deltaTime).normalized; + // 현재 방향을 목표 방향으로 보간 (유도력 적용) + Vector3 newDirection = Vector3.Lerp(transform.forward, direction, homingStrength * Time.deltaTime).normalized; - // 새로운 방향으로 이동 - transform.position += newDirection * speed * Time.deltaTime; + // 새로운 방향으로 이동 + transform.position += newDirection * speed * Time.deltaTime; - // 투사체가 이동하는 방향을 바라보도록 회전 - transform.forward = newDirection; + // 투사체가 이동하는 방향을 바라보도록 회전 + transform.forward = newDirection; - yield return null; + yield return null; - m_ProjecTileData.LifeTime -= Time.deltaTime; + m_ProjecTileData.LifeTime -= Time.deltaTime; + } + else + break; } Off(true);