0 votes

I am using a speed variable in a enemy script.i want to change its speed when player collided with some area.enemy was instances from a enemy spawner node.
When I changed variable value it affect spawned enemy only..I want movespeed To affect all of my enemy.i am using a single script for all enemy

Godot version 3.3
in Engine by (12 points)
edited by

1 Answer

0 votes

Add all those enemies to a group

var _ready():

Use sceneTree's group call and object's set property

get_tree().call_group("ENEMY", "set", "movespeed", 600)

Or add all enemy nodes as child of one node and loop through each node setting that value

for child in parent_node.get_children():
    child.movespeed = 600
by (4,644 points)

Thanks. ☺️☺️

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.