April 2021
Beginner to intermediate
506 pages
11h 57m
English
Switch to the GeneratorComponent.swift file. In the spawnMonsterEntity(), add the following code below the line that reads monsterEntity.addComponent(healthComponent):
| | let agentComponent = AgentComponent() |
| | monsterEntity.addComponent(agentComponent) |
While you’re here, also add the physics component not only to the monsters being spawned, but also to the generator itself. By adding the physics component here, you won’t need to worry about adding it to your generators when you add them to the scene using the Scene Editor, saving you an additional step.
Below the code you just added, add the following code:
| | let physicsComponent = PhysicsComponent() |
| | physicsComponent.bodyCategory = PhysicsCategory.monster.rawValue ... |
Read now
Unlock full access