I am working on a tank game with a world, a tank object, and a boss object. The world is created, then the boss, then the tank. The tank is passed a pointer to the boss object to allow for tank-boss communication without world intervention (for collision events and other things).
When the tank passes through a certain volumetric trigger, it tells the boss to activate. I want the boss to continually face the tank using the lookAt command. The problem is that the boss doesn’t know about the tank, and I can’t pass the boss a pointer to the tank because the boss is created first, and there’s a circular dependency there.
Since the tank knows about the boss, and since I already have a task on the tank handling movement, I wanted to the tank to pass the boss it’s own position in a task, updating boss.tankPos every frame. The problem I am having is passing the bossPointer to the task.
I currently enable the tank movement task in the following way:
# add a task to handle tank movement taskMgr.add(self.handleMovement, "handleMovement")
I tried adding bossPointer in there, both as an argument, and as a list, and it didn’t like it. How can I edit my handleMovement task initialization so that the bossPointer gets passed to the task?
I want to do this without making the bossPointer an actual attribute of the tank class, because that would create a local copy of the boss, which isn’t what I want.