Skip to content

Commit 12188c5

Browse files
committed
Make NPC wait for a random time before walking away in cutscene
1 parent 1bc90f5 commit 12188c5

File tree

1 file changed

+7
-1
lines changed
  • UOP1_Project/Assets/Scripts/Characters

1 file changed

+7
-1
lines changed

UOP1_Project/Assets/Scripts/Characters/NPC.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections;
2-
using System.Collections.Generic;
32
using UnityEngine;
43

54
public enum NPCState { Idle = 0, Walk, Talk};
@@ -11,6 +10,13 @@ public class NPC : MonoBehaviour
1110

1211
public void SwitchToWalkState()
1312
{
13+
StartCoroutine(WaitBeforeSwitch());
14+
}
15+
16+
IEnumerator WaitBeforeSwitch()
17+
{
18+
int wait_time = Random.Range(0, 4);
19+
yield return new WaitForSeconds(wait_time);
1420
npcState = NPCState.Walk;
1521
}
1622
}

0 commit comments

Comments
 (0)