What’s wrong with this code?
c = GameLogic.getCurrentController()
a = c.owner.actuators[0];
a.instantAddObject();
bike = a.objectLastCreated;
#let everyone know
GameLogic.number_of_baddies +=1;
#setup:
bike['range'] = 30 + 20*(GameLogic.getRandomFloat() -0.5)
bike['speed'] = 20 + 5 * GameLogic.kills + (10 * (GameLogic.getRandomFloat()-0.5) );
bike['evade_speed'] = 100 + 50 * GameLogic.kills + (200 * (GameLogic.getRandomFloat()-0.5) );
bike['attack_freq'] = 0.9 + (GameLogic.getRandomFloat()-0.5)/10.0;
bike['HP'] = 1;
a is an Add Object brick connected to the script. The object to add is already entered in the brick.
Thing is, this script works for one object but not another; When I later try to use the speed, range, etc. variables I get this old error:
KeyError: 'value = gameOb[key]: KX_GameObject, key "speed" does not exist'
The objects are for all intents and purposes identical (same code, different mesh object). What could possibly be causing this?