I’m trying to develop a method for spreading fire along a ground plane, like so:
- A “fireball” is launched
- When it hits the ground, it spawns a piece of “firewood”
- After a pause, the firewood spreads in a grid fashion, to adjacent squares
- These new pieces of firewood will again spread in similar fashion
However, the python script for my blocks of firewood creates errors after spawning the second generation of firewood.
I wrote a finite state machine within a class called Firewood, with this basic structure:
class Firewood(types.KX_GameObject): def __init__(self, own): self.main = self.state_idle def state_idle(self): foo ... def main(cont): own = cont.owner if not "init" in own: own["init"] = True own = Firewood(own) own.main()
However, the second generation of firewood spawns and gives this attribute error:
Python script error - object 'firewood', controller 'Python': Traceback (most recent call last): File "C:\...\fire_propogation\firewood.py", line 94, in main own.main() AttributeError: 'KX_GameObject' object has no attribute 'main'
Does the game engine not play nicely when objects use the same code? Am I making a logic error in how I control the firewood’s state changes?
fire_prop.zip (90.8 KB)