How to target doppelganger?

I know how to target types: if (enemy.type == "sand-yak") ..., but I don’t know how to target a particular enemy, like my doppelganger. What is their enemy.type? Or can I select them by name? I did try if (enemy == "amara") ... as an example, but it doesn’t seem to work.

Any hints?


You could use if ( == "Amara") {, but I don’t think that works.

As an alternative, you could use if (enemy.type == this.type) {. That should work better.

Ahh, I haven’t been introduced to id yet. It did not work.

The second method did work! So, how does it work? I’m assuming the Doppelganger as the same type as my hero?

Thanks again, Chronist!

Depending on the level, it might not be a doppelganger! Remember that. They should have the same name, however. You can always find out their name by using cycling through the enemies with:

enemies = self.findEnemies()
    for enemy in enemies:

On the multiplayer levels it’s often something like “Hero Placeholder” or “Hero Placeholder 1”.

I know this is “solved” but another thread had some good related information Easiest way to select the enemy hero

1 Like