npc暂时不能移动
This commit is contained in:
parent
fbc97ff6f5
commit
3d84708b83
@ -21495,8 +21495,8 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 44720823678ca7c42a08f4409ab025ff, type: 3}
|
m_Script: {fileID: 11500000, guid: 44720823678ca7c42a08f4409ab025ff, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
serverIP: ws://222.212.4.120
|
serverIP: ws://192.168.3.110
|
||||||
serverPort: 2387
|
serverPort: 8445
|
||||||
type:
|
type:
|
||||||
--- !u!114 &1526740604
|
--- !u!114 &1526740604
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
@ -45,7 +45,7 @@ public class RecuseNpc : MonoBehaviour
|
|||||||
instance = this;
|
instance = this;
|
||||||
//recusebtn = GameObject.Find("Canvas/Recuse").GetComponent<Button>();
|
//recusebtn = GameObject.Find("Canvas/Recuse").GetComponent<Button>();
|
||||||
anim = this.GetComponent<Animator>();
|
anim = this.GetComponent<Animator>();
|
||||||
target = transform.Find("mubiao").GetComponent<Transform>();
|
target = GameObject.Find("mubiao").GetComponent<Transform>();
|
||||||
navMeshAgent = GetComponent<NavMeshAgent>();
|
navMeshAgent = GetComponent<NavMeshAgent>();
|
||||||
|
|
||||||
// 初始化 NavMeshAgent 的一些属性
|
// 初始化 NavMeshAgent 的一些属性
|
||||||
@ -87,7 +87,9 @@ public class RecuseNpc : MonoBehaviour
|
|||||||
public void SetNpcDes(Vector3 tar)
|
public void SetNpcDes(Vector3 tar)
|
||||||
{
|
{
|
||||||
Debug.Log(tar);
|
Debug.Log(tar);
|
||||||
|
|
||||||
target.position = tar;
|
target.position = tar;
|
||||||
|
Debug.Log(target);
|
||||||
NavMeshHit hit;
|
NavMeshHit hit;
|
||||||
if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas))
|
if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas))
|
||||||
{
|
{
|
||||||
@ -97,6 +99,7 @@ public class RecuseNpc : MonoBehaviour
|
|||||||
{
|
{
|
||||||
tar = hit.position; // 将目标点调整到最近的导航网格位置
|
tar = hit.position; // 将目标点调整到最近的导航网格位置
|
||||||
}
|
}
|
||||||
|
Debug.Log("进入奔跑++++++=");
|
||||||
targetPoints.Add(tar);
|
targetPoints.Add(tar);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -119,9 +122,10 @@ public class RecuseNpc : MonoBehaviour
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.Log("++++++++++++++++++++++++++++" + targetPoints.Count);
|
||||||
if (targetPoints.Count > 0)
|
if (targetPoints.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
currentTarget = targetPoints[0];
|
currentTarget = targetPoints[0];
|
||||||
nstate = Npcstate.run;
|
nstate = Npcstate.run;
|
||||||
movebool = true;
|
movebool = true;
|
||||||
@ -168,6 +172,7 @@ public class RecuseNpc : MonoBehaviour
|
|||||||
|
|
||||||
public void Run(Vector3 target)
|
public void Run(Vector3 target)
|
||||||
{
|
{
|
||||||
|
Debug.Log("进入奔跑");
|
||||||
if (movebool)
|
if (movebool)
|
||||||
{
|
{
|
||||||
// 确保目标点在 NavMesh 上
|
// 确保目标点在 NavMesh 上
|
||||||
|
Loading…
Reference in New Issue
Block a user