Hi, I could connect to all car instances but still unable to make them react "individually" (each car should stop only when hit Area)
Tree:
World
-Car
-Car2
-Area
Area:
extends Area
signal hit
func _on_Area_body_entered(body):
emit_signal("hit")
Car:
extends KinematicBody
var speed = 10
func _ready():
add_to_group("Car")
var cars = get_tree().get_nodes_in_group("Car")
for Car in cars:
$"../Area".connect("hit", self, "_stop")
func _process(delta):
var velocity = Vector3.ZERO
velocity.z -= speed * delta
move_and_collide(velocity)
func _stop():
if self.is_in_group("Car"):
print("stop")
speed = 0
else:
print("fail")