private void Update() { // when we get close, set up the if (Vector2.Distance(fake_leader, center_target.transform.position) < 0.75f) { if (center_target.next_target) { center_target = center_target.next_target; } } int num_far_count = members.Count; for (int i = 0; i < members.Count; ++i) { members[i].dest = fake_leader + member_leader_delta[i]; if (Vector2.Distance(members[i].transform.position, members[i].dest) > 0.5f) { num_far_count--; } } //print(num_far_count); fake_leader += movespeed * (float)num_far_count / members.Count * ((Vector2)center_target.transform.position - fake_leader).normalized * Time.deltaTime; //fake_leader += movespeed * ((Vector2)center_target.transform.position - fake_leader).normalized * Time.deltaTime; }
private void OnTriggerEnter2D(Collider2D collision) { DestTrigger dt = collision.GetComponent <DestTrigger>(); if (dt) { //print("hit trigger" + dt.name); if (dt.next_target) { cur_dest = dt.next_target; } } }