Okay I am new to Godot and have the latest release 3.1 and I am developing on Windows 10 operating system.
This project is a simple copy of the original space invaders video game. At the moment I have two scenes one called Game (Node node) and another called Invader (KinematicBody2D node). The Game is the main scene and contains an Area2D node used to define the Invader area.
The Invader scene is instantiated by the Game node using:
Export (PackedScene) var Invader
var invader = Invader.instance()
I add 5 rows of these Invaders to the Game Scene. This all works fine but as I march them across the Invader area I wish them to reverse direction, when the farthest Invader exits the area. I use the Body Exited Signal to trigger this occurrence – to the Game script. This is also working fine.
However what is not working – at least as expected – is a Singleton script which I created which contains a flag telling the Invaders when to reverse the direction of their march. The script is called Controller and has a single variable flip.
Now this is what I do not understand, when the Invaders trigger the Body Exited Signal only the FIRST Invader that was instantiated reverses direction all the others continue to march on. The march method is found in a script attached to the invader KinematicBody2 node (Invader Scene). This method has a simple condition statement like – if Controller.flip = true :
What am I missing. I have used a Controller Singleton in the past in an earlier version of Godot and this is the first time I have not understood the result.
Your assistance would be greatly appreciated.