EDITED: okay so while I am still looking for help with this, I just realized the MASSIve frame rate drop was due to me having the wrong physics settings accidentally on the big gargoyle dude. woops. (on a side note, is there anyway to have a ‘character’ type physics object not have infinite pushing power against a rigidbody / dynamic with high mass?)
So at thanksgiving my aunt suggested I run my scripts as modules to increase the performance of the CPU while the game is running.
I have all my enemeis scripted, and they look and act great, but they drop my frame rate down to 2 fps, even with them being relatively low poly (about 1000-2000 each, with maybe 10 on screen? I might just have to decimate them into ugly pokey things?)
I haven’t used these before, and I am having a bit of trouble.
I understand that you change ‘Script’ to ‘Module’ in the python controller. Then I understand you type the name of the function, after a dot, after the ‘Module’ name, which is the same as the script name.
The thing is, the script normally was just a script without a main function. When I put it all in a main function so that I would have a function to type in after the module name on the python controller, and did so, I get the error:
‘Cannot add actuator from non active controller’
I am not exactly sure why that is happening.
The script is for an enemy searching. The script works fine, so that’s not the problem, but its there below. All of the enemies have the same general scripts on them, which is why I wanted to change them to 'Module’s I guess… I.E. they all have the same search, pursue, attack, turnaround, general scripts on them with just some parameters changed by unique game properties. Anyway, help solving what elements of these scripts need to be in functions for them to work as modules would be appreciated.
‘Search’ script example:
from bge import logic, renderfrom mathutils import Vector gd = logic.globalDict obj = logic.getCurrentScene().objects cont = logic.getCurrentController() own = cont.owner ray = cont.sensors['Ray'] radar = cont.sensors['Radar'] near = cont.sensors['Near'] msgarmature = cont.actuators['MsgArmature'] pursuestate = cont.actuators['PursueState'] turnstate = cont.actuators['TurnState'] updown = Vector([0,0,1]) own.alignAxisToVect(updown,2,1) rd1 = own['Rotate'] rd2 = own['RDirect2'] if radar.positive: ('printradar') forward = Vector([rd1,rd2,0]) print(forward) forward.magnitude = own['Speed'] own.alignAxisToVect(forward,1,1) own.applyMovement(forward) msgarmature.subject = 'Walk' cont.activate(msgarmature) else: cont.activate(turnstate) if near.positive or ray.positive: cont.activate(pursuestate)