-
Notifications
You must be signed in to change notification settings - Fork 0
/
bots_random_animations.cs
51 lines (40 loc) · 1.28 KB
/
bots_random_animations.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bots_random_animations : MonoBehaviour
{
private Animator[] m_bots;
[SerializeField] private int m_nb_animations;
// Start is called before the first frame update
void Start()
{
m_bots = GetComponentsInChildren<Animator>();
InvokeRepeating("Bot_Animation", 1f, 2f); //1s delay, repeat every 1s
}
// Update is called once per frame
void Update()
{
}
void Bot_Animation()
{
for (int i = 0; i < m_nb_animations; i++)
{
int index = Random.Range(0, m_bots.Length);
// bot is doing no animation
if (m_bots[index].GetCurrentAnimatorStateInfo(0).IsName("sit"))
{
//Debug.Log(index);
//// cant implicitly convert int to bool.. fckn compiler
int action = Random.Range(0, 2);
if (action == 0)
{
m_bots[index].SetBool("Laught", true);
}
else if (action == 1)
{
m_bots[index].SetBool("Talk", true);
}
}
}
}
}