# Zombie-Survivor target finding?

**URL:** <https://forum.kirupa.com/t/zombie-survivor-target-finding/325441>\
**Category:** programming\
**Created:** [October 16, 2011, 1:40am UTC](https://forum.kirupa.com/t/zombie-survivor-target-finding/325441 "2011-10-16T01:40:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![narfnin](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@narfnin](https://forum.kirupa.com/u/narfnin)\
**Post date:** [October 16, 2011, 1:40am UTC](https://forum.kirupa.com/t/zombie-survivor-target-finding/325441/1 "2011-10-16T01:40:12Z")

</div>

So I have two arrays, survivors and zombehz, and I want elements from one (a survivor) to set an element from the other (a zombie) as its target, and to shoot said target until it dies.

Conversely, I want the zombies to find a survivor and hunt after them.

I can’t figure out how to make this work though.  
Code below

**Zombies:**

```auto
if (Foe == false) {
            target = _root.Tracker.survivors[Math.ceil(Math.random()*_root.Tracker.survivors.length)];
            Foe == true;
        } else {
attack code (already tested)

```

**Survivors:**

```auto
if (Foe == false) {
            target = _root.Tracker.survivors[Math.ceil(Math.random()*_root.Tracker.survivors.length())];
            Foe == true;
        } else {
shooting code (already tested)

```

Can someone help me? And also, as an FYI, if I make a non-array based object that is directly controlled, it can shoot and kill zombies, but I can’t make them pick targets in the other arrays.
