0 votes

Is there an easy way to get a certain type of children of a node ?

Say I have a spatial node with children of different structure, ex:

spatial node: (3 children)
- Enemy 1 => 2 rigid bodies, 3 meshes
- Enemy 2 => 1 rigid body, 1 mesh
- Enemy 3=> 3 rigid bodies, 5 meshes

I want to "select" a certain type of Enemy children and do a modification,
ex: set mesh textures to null, or change rigid body to static...

Is there an easy way to do that, without looping over each enemy manually and so on?

Thx in advance

asked Nov 10, 2019 in Engine by GameVisitor (812 points)

1 Answer

0 votes

You could assign them to a group e.g("Enemy") and check if they belong in there

EnemyInstance.addtogroup("SpecialEnemy")
You could assign them through inspector for less code

EnemyReference.isingroup("SpecialEnemy")

answered Nov 11, 2019 by LoneDespair (315 points)

Thx for ur reply, but i am not looking to select / manipulate the enemies per se.

In one case I want to change the (6) rigid bodies to static
In another case, i want to change the (9) meshes' color to red.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.