feat: units hold formation while patrolling
This commit is contained in:
parent
c05d3aa28f
commit
ec6fc76335
7 changed files with 31 additions and 11 deletions
|
|
@ -18,8 +18,11 @@ void NpcUnit::child_added(Node *node) {
|
|||
if (EnemyBody * npc{ cast_to<EnemyBody>(node) }) {
|
||||
this->npcs.push_back(npc);
|
||||
npc->set_unit(this);
|
||||
PlayerDetector *detector{ cast_to<PlayerDetector>(npc->get_node(NodePath("%PlayerDetector"))) };
|
||||
detector->connect(PlayerDetector::sig_awareness_changed, callable_mp(this, &self_type::on_npc_awareness_changed));
|
||||
Vector3 const offset{ npc->get_global_position() - get_global_position() };
|
||||
npc->set_unit_offset({ offset.x, offset.z });
|
||||
if (PlayerDetector * detector{ cast_to<PlayerDetector>(npc->get_node(NodePath("%PlayerDetector"))) }) {
|
||||
detector->connect(PlayerDetector::sig_awareness_changed, callable_mp(this, &self_type::on_npc_awareness_changed));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue