# Apple Game Frameworks and Technologies - Adding monster entity to scene array (779)

**URL:** <https://forum.devtalk.com/t/apple-game-frameworks-and-technologies-adding-monster-entity-to-scene-array-779/5697>\
**Category:** PragProg Customers\
**Tags:** book-apple-game-frameworks-and-technologies, errata\
**Created:** [6 January 2021 09:20 UTC](https://forum.devtalk.com/t/apple-game-frameworks-and-technologies-adding-monster-entity-to-scene-array-779/5697 "2021-01-06T09:20:51Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![cocojas](https://forum.devtalk.com/user_avatar/forum.devtalk.com/cocojas/32/1011_2.png) [@cocojas](https://forum.devtalk.com/u/cocojas)\
**Post date:** [6 January 2021 17:23 UTC](https://forum.devtalk.com/t/apple-game-frameworks-and-technologies-adding-monster-entity-to-scene-array-779/5697/3 "2021-01-06T17:23:59Z")

</div>

Hi Tammy,

No worries, I struggled a lot with how to explain it, especially since e-readers constantly renumber pages 🙂

The actual agent simulation is working, but in the first half of the chapter (Chapter 13—Planning Routes and Creating Believable AI), if the reader is following along doing the coding, the monsters themselves won’t be participating in the update cycle since the MonsterEntity (that get created by the generators) are not yet in the scene’s entity array. The code that gets the monster to choose to chase the player (changes the goal weight for the `interceptGoal`) comes near the end of the section _Use Multiple Goals_, where the reader adds an `update` method to `MonsterEntity`.

But, the code to update the adding the monster entities into the scene’s entity array isn’t added until later in the chapter, specifically near the end of the section _Update Physics for Monsters and Projectiles_. So when the reader first tests picking up the key after adding the chase code, the monsters aren’t going to chase them, because the `MonsterEntity`'s `update` function won’t be triggered yet. I think just relocating the code block that does that to the earlier section would fix it.

```auto
if let scene = ocmponentNode.scene as? GameScene {
    scene.entities.append(monsterEntity)
}

```

---

_[View the full topic](https://forum.devtalk.com/t/apple-game-frameworks-and-technologies-adding-monster-entity-to-scene-array-779/5697)._
