I want to use Blender to make a dynamic character. I want to know if it is possible to make a number of keyframes for facial expressions and then have the ability (using python's game engine) to choose which face I want the current face to morph into?
Ok, so I have been trying to master Python scripting with Blender's Game Engine. I would like to make a basic game where you can tell the face, within the Python Console, what expression to do, running code from the Text Editor. Here is some code I wrote in the text editor after making two keyframes 'Basis' and 'Surprise' in Blender Render:
def Face(Expression): if Expression == 'basis': C.object.data.shape_keys.key_blocks['Basis'].value=0.0 #I believe this should make the animation morph to the Basis as defined in my key frame print('basis') elif Expression == 'surprise': C.boject.data.shape_keys.key_blocks['Surprise'].value=1.0 #Again this is defined in my key frame print('surprise') else: print('invalide entry')
When I click Run Script it seems to compile with no errors. When I enter the Python Console and type "Face('basis')" I get the following error:
Traceback (most recent call last): File "<blender_console>", line 1, in <module> NameError: name 'Face' is not defined
Firstly is the game engine capable of making a game where you can change character's facial expressions. Would it be better to manipulate bones in the face rather than morphing between key frames? And, how do I call the function I wrote in the text editor in the Python Console? I also want to know if I called the 'object.shape_key' from C properly from the python code? Very detailed Q I know, thanks for the help guys!