I was wondering about setting up multiple zombies and animations.

I am currently working on a zombie game and don’t understand how to set up multiple zombies, like I know how but when I put the animation on all of them they all start the animation at the same time is there a way to randomize when the animation starts on the same animation on multiple zombies?

Create A Script And Write:

-JAVASCRIPT:

public var value : float = 0;
public var min : float = 0;
public var max : float = 5;
private var anim : Animator;
public function Update () {if(anim)anim.SetFloat("Random",value);}
public function Awake () {if(GetComponent(Animator))anim = GetComponent(Animator);value = Random.Range(min,max);}

-C# (Not Sure If Works):

using System.Collections.Generic;
using UnityEngine;
public class YourScriptName : MonoBehaviour
{
	public float value = 0f;
	public float min = 0f;
	public float max = 5f;
	private Animator anim;
	public void Update () {if(anim)anim.SetFloat("Random",value);}
	public void Awake () {if(GetComponent<Animator>())anim = GetComponent<Animator>();value = Random.Range(min,max);}
}

Then Go To The Zombie Animator You Have, And Add A Parameter In The Animator Type Of (float), Then Call It “Random”, And Set Different Transitions Between Clips You Want In The Animator To Randomize, Then Click The (+) Button And Again To Create It Twice And Select (Randomize) In Both And Set Each Of Them Between 2 Numbers Like 0 And 1 And In Another Clip Set 1 And 2 And In Another Clip Set 2 And 3 etc… Then Set Minimum Number To (Greater) Option And Maximum Number To (Less) Option, For Example:
I Have 1 And 2, Set 1 To (Greater), And Set 2 To (Less).
And Done :wink:

above answer sounds good to me, I’ll have to try that. But the way I did it was to vary the animation speeds for each character. they would still start all the same so for a second or so will look identical but as they loop at different speeds in a few seconds they look different .Randomizing seems better way where I had set mine to be a public variable for the same script on each enemy

public float Speed;
Animation anim;


void Start(){
anim = GetComponent<Animation>();
anim["enemyWalk"].speed = Speed;