Bulletforce script from Socials's FPS Template

Hi, I’m having some problems with the bulletforce script contained in Social’s FPS template. The problem occurs when I try to use the script in my own .blend (Also a FPS template). The script doesn’t function the way it should even though I have recreated what is called for in the script, It gives me an error message in the console saying "AttributeError: ‘NoneType’ object has no attribute ‘setOrientation’. Any help with this problem would be appreciated, attached is my .blend and Social’s FPS template.
-Thanks, Kingofthecrows.

Attachments

MyFail.blend (167 KB)

I’ve never seen Social’s template and I’m kind of too lazy to look at your .blend, but I know what that error means. Whatever line in the script is creating this error is supposed to get an object (either from the scene, from an add object actuator or from somewhere else) and change it’s orientation. Problem is, that object doesn’t exist in your game. Create the object it’s calling for and it should fix itself.

One more thing, if its getting the last created object from an add object actuator, it may give this error if actuator isn’t activated before that line of code. If this is the case, rearranging the lines could solve it.

If all else fails, put

try:
before the error-inducing line of code, indent it, and then right underneath it type
except:
pass

This will make the script just skip that line if it doesn’t work.

Oh, and setOrientation is deprecated. Now you would do object.worldOrientation=[man, bear, pig] or whatever.

Yeah I´ve got same problems: lastAddedObject, it cant handle with orientation after few shots.
If someone can repair that script. Please do it and post it here.

Thanks for all (and sorry for english)

I aggree with Magnus Opus, the last created bullet does not axist anymore, Because it lives just 2 ticks.

Modify line 13 to this one:

 
if own.force and ray_all.isPositive() <i>and forceobj != None</i>:

This is just a quick fix, without checking the logic at an higher level, but it should solve your problem.

Compared with socials template you execute the BulletForce.py with the left mouse click too. Social’s script does not do that.

This means you logic violates the (unwritten) assumptions of the script. (The assumption is: The bullet still exist when the script is executed.)

I hope it helps