Play random animation on an instantiated prefab
Hello
I have tried to play random animation on an random instantiated prefab in a random place. To do that, i used this code. c.f) i used integer parameter named "playState", "sittingId" and i confirmed there is no typo. and when i changed parameter, the animator works.
public Animator anim;
void Start()
{
anim = GetComponent<Animator>();
anim.SetInteger("playState", 1);
if (SceneManager.GetActiveScene().buildIndex == 1)
{
if (playState == 0)
{
for (int i = 0; i < 24; i++)
{
Num = Random.Range(0, 3);
if (Num == 1)
{
GameObject obj2 = Instantiate(Resources.Load("preChar/ybot 1"), Present_Position[i], Quaternion.identity) as GameObject;
obj2.transform.localScale += new Vector3(2, 2, 2); // 크기
obj2.transform.rotation = Quaternion.Euler(0, 90, 0); // 방향
obj2.GetComponent<Animator>().SetInteger("sittingId", Random.Range(0, 4));
}
else if (Num == 2)
{
;
}
else
{
;
}
}
}
i have a character for comparing prefab. and only it works not only prefabs but character.
how can i fix this problem?
please let me know the way
thanks for reading
Good day.
I dont understand what you need. What you want to get? what is happening, etc.
Please know more than 70% of users are not English, so try to do a good explanation so everyone can undestand your problem.
Bye!
thanks for replying. i have solved this problem by using setActive. I will explain more detail next time.