Question by
unity_9776mk · Sep 10, 2018 at 12:29 PM ·
animatorparametersset
animator.setInteger doesn't work
Hello
I have a animator that starts when the game starts and instantiates prefab.
It works for Instantiating prefab, but It doesn't change the number of parameter
When i changed parameter manually, the animator works.
The codes are followed.
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 obj1 = Instantiate(Resources.Load("preChar/ybot 1"), Present_Position[i], Quaternion.identity) as GameObject;
//GameObject obj2 = Instantiate(g, Present_Position[i], Quaternion.identity) as GameObject;
obj1.transform.localScale += new Vector3(2, 2, 2); // 크기
obj1.transform.rotation = Quaternion.Euler(0, 90, 0); // 방향
obj1.SetActive(true);
anim.GetComponent<Animator>().SetInteger("sittingId", Random.Range(0, 4));
//obj1.GetComponent<Animator>().SetInteger("sittingId", Random.Range(0, 4));
anim.Rebind();
}
else if (Num == 2)
{
/* GameObject obj = Instantiate(Resources.Load("preChar/StudioNewPunch/SuitPack/SuitedMan/Models/BlueSuitFree01"), Present_Position[i], Quaternion.identity) as GameObject;
obj.transform.localScale += new Vector3(2, 2, 2);
obj.transform.rotation = Quaternion.Euler(0, 90, 0);
*/
}
else
{
;
}
}
}
}
Let me know the problem.
Thanks for reading.
Comment
Your answer
Follow this Question
Related Questions
Why my animator is freezzed after WaitForSeconds(Delay) 1 Answer
Why can't I delete animator parameters? 2 Answers
[Solved]There is a delay between setInteger and the animation 1 Answer
Can't rearrange animation parameters 0 Answers
Can I make a prefab have different sprites based on what direction it is facing? 1 Answer