![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Ray Alez |
Hi! I’m new to godot, and I’m going through the excellent Tank Battle tutorial series.
One thing that confuses me is keeping track of signals and variables between multiple files. For example, this course teaches how to create self-guiding misslie that automatically pursues it’s target(player). When it’s all done, here’s what it takes to pass the player object to the missile:
- EnemyTank has a collision shape that sends it a signal when player enters it’s radius, setting the “target” variable(that I now need to pass to the missile).
- When it’s time to shoot a missile, EnemyTank calls a shoot() method of Tank(it’s parent class), passing it the “target”.
- Tank emits a signal telling the level Map to spawn the Bullet(because bullet needs to be parented to the level, not to the tank), passing “target” along.
- Map spawns the Bullet, and calls a method on the Bullet object, passing the “target” to it.
- And then Bullet finally uses the “target” to steer towards player.
I wanted to ask - is this kind of thing normal in godot? If yes, then how can I manage this complexity, or document it somehow? Because I can’t imagine how a different programmer(or even me in a few months), looking at a Bullet script and trying to figure out where does the “target” come from, would untangle all this. Tracing things backwards would be so hard, there are so many scripts, and no obvious way to find out what calls the method I’m looking at.
Extensive commenting could work, but doesn’t seem ideal, I’d have to explain this whole thing in 5 places in my code to make it clear where does the “target” object come from, where it’s going, and why.
Any advice?