修改后2龙不自动面向玩家问题
This commit is contained in:
@@ -45,9 +45,20 @@ public class BlackDragon : Enemy
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (isAlive)
|
||||
//if (isAlive)
|
||||
//{
|
||||
// UpdateLookRotation();
|
||||
//}
|
||||
if (isAlive && GameManager.Ins._player != null && state == EnemyState.Atk)
|
||||
{
|
||||
UpdateLookRotation();
|
||||
Vector3 direction = GameManager.Ins._player.transform.position - transform.position;
|
||||
direction.y = 0;
|
||||
|
||||
if (direction != Vector3.zero)
|
||||
{
|
||||
// 直接设置旋转,不使用插值
|
||||
transform.rotation = Quaternion.LookRotation(direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,15 +119,15 @@ public class BlackDragon : Enemy
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateLookRotation()
|
||||
{
|
||||
if (GameManager.Ins._player != null&& state== EnemyState.Atk)
|
||||
{
|
||||
Vector3 lookDir = GameManager.Ins._player.transform.position - transform.position;
|
||||
lookDir.y = 0;
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(lookDir), Time.deltaTime * 5);
|
||||
}
|
||||
}
|
||||
//public void UpdateLookRotation()
|
||||
//{
|
||||
// if (GameManager.Ins._player != null&& state== EnemyState.Atk)
|
||||
// {
|
||||
// Vector3 lookDir = GameManager.Ins._player.transform.position - transform.position;
|
||||
// lookDir.y = 0;
|
||||
// transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(lookDir), Time.deltaTime * 5);
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 普通攻击一次
|
||||
|
||||
@@ -44,9 +44,21 @@ public class LightingDragon : Enemy
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (isAlive)
|
||||
//if (isAlive)
|
||||
//{
|
||||
// UpdateLookRotation();
|
||||
//}
|
||||
//最简单直接的转向
|
||||
if (isAlive && GameManager.Ins._player != null && state == EnemyState.Atk)
|
||||
{
|
||||
UpdateLookRotation();
|
||||
Vector3 direction = GameManager.Ins._player.transform.position - transform.position;
|
||||
direction.y = 0;
|
||||
|
||||
if (direction != Vector3.zero)
|
||||
{
|
||||
// 直接设置旋转,不使用插值
|
||||
transform.rotation = Quaternion.LookRotation(direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,15 +117,15 @@ public class LightingDragon : Enemy
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateLookRotation()
|
||||
{
|
||||
if (GameManager.Ins._player != null&& state== EnemyState.Atk)
|
||||
{
|
||||
Vector3 lookDir = GameManager.Ins._player.transform.position - transform.position;
|
||||
lookDir.y = 0;
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(lookDir), Time.deltaTime * 5);
|
||||
}
|
||||
}
|
||||
//public void UpdateLookRotation()
|
||||
//{
|
||||
// if (GameManager.Ins._player != null && state == EnemyState.Atk)
|
||||
// {
|
||||
// Vector3 lookDir = GameManager.Ins._player.transform.position - transform.position;
|
||||
// lookDir.y = 0;
|
||||
// transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(lookDir), Time.deltaTime * 20);
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 普通攻击一次
|
||||
|
||||
Reference in New Issue
Block a user