IEnumerator Start() { this.rigidbody = GetComponent <Rigidbody2D>(); this.feet = GetComponent <FeetPosition>(); while (true) { float sleepTime = Random.Range(this.sleepTimeMin, this.sleepTimeMax); yield return(new WaitForSeconds(sleepTime)); float walkAngle = Random.Range(0, 360); this.rigidbody.velocity = Vector2.up.Rotate(walkAngle) * this.walkSpeed; float walkTime = Random.Range(this.walkTimeMin, this.walkTimeMax); yield return(new WaitForSeconds(walkTime)); this.rigidbody.velocity = Vector2.zero; } }
void Start() { this.animator = GetComponent <Animator>(); this.rigidbody = GetComponent <Rigidbody2D>(); this.feet = GetComponent <FeetPosition>(); }