game: the npc walks fully

This commit is contained in:
ryan 2025-02-05 19:26:49 +08:00
parent 88cdc90474
commit b17824d8b1
2 changed files with 18 additions and 3 deletions

View file

@ -58,6 +58,10 @@ public class NpcMovementRework : MonoBehaviour
public void Wait() public void Wait()
{ {
Debug.Log("walking"); Debug.Log("walking");
if (animator.GetBool(IsSitting))
{
animator.SetBool(IsSitting,false);
}
agent.SetDestination(roamingPoint); agent.SetDestination(roamingPoint);
} }
@ -79,8 +83,8 @@ public class NpcMovementRework : MonoBehaviour
if (dist <0.5) if (dist <0.5)
{ {
agent.SetDestination(gameObject.transform.position); agent.SetDestination(gameObject.transform.position);
gameObject.transform.position=sittingPosition;
gameObject.transform.rotation = pos.transform.rotation; gameObject.transform.rotation = pos.transform.rotation;
gameObject.transform.position=sittingPosition;
animator.SetBool(IsSitting,true); animator.SetBool(IsSitting,true);
yield break; yield break;
} }
@ -88,7 +92,11 @@ public class NpcMovementRework : MonoBehaviour
yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame();
} }
} }
public void Despawn()
{
var random= Random.Range(0, NpcManager.instance.despawnPoints.Length);
agent.SetDestination(NpcManager.instance.despawnPoints[random].position);
}

View file

@ -51,7 +51,14 @@ public class NpcManager : MonoBehaviour
/// </summary> /// </summary>
public GameObject[] currentNpcs; public GameObject[] currentNpcs;
/// <summary>
/// a collection of positions for the chairs to sit for the npcs
/// </summary>
public GameObject[] chairPositions; public GameObject[] chairPositions;
/// <summary>
/// a collection of positions for the npcs to despawn
/// </summary>
public Transform[] despawnPoints;
public void spawnNpc(bool isFemale, Transform spawnPoint) public void spawnNpc(bool isFemale, Transform spawnPoint)
{ {