Control armature in BGE

I have an animated armature loaded from a bvh file. I wonder how I can control it’s bones rotations from BGE? What I’m trying to do is once the game is played the armature and animation will be paused, once press P again the animation will play from a couple of frames back(e.g paused at frame 100, replay will play from frame 90) and when pressing P again it will pause (I already did that), once it’s posed, I want to select any bone of the armature (e.g RightArm) and modify it’s rotation by using any other keys to add/subtract a threshold to the current rotation. Once the rotation is modified I want to save it to my animation so that when I resume my animation (which will play from a couple of frames earlier) the rotation will be smoothend so that no flickering happens.
Example with steps:

  • game engined played with P the animation will be in pause state
  • when pressing P the animation will play
  • at frame 100 P is pressed again the animation will pause at frame 100
  • the RightArm rotation of this frame is lets say x= 100, y=0, z=0, the rotation will be modified using keys such as W S A D keys to be x=200, y=10 , z=50
  • once the needed rotation is set, press P again the animation will be played but 10 frames earlier so it will start playing from frame 90, but in those 10 frames between 90-100 the rotation will need to be interpolated so that the rotation around X for example doesn’t jumps from 100 to 200, it needs smooth interpolation. Same will be needed for frames between 100 and 110 so that arms goes up and down smoothly.
  • The modified animation will be saved so when the animation is replayed from the begining the rotation modifications will be seen.

My current blend file can be found here

you could use objects with the armature targeting them with copy rotation constraint ?

(many constraints work in the game engine, but only for armatures)

remember to use ‘run armature’

Thanks for your reply. Could you please show me how this can be done as I’m pretty new in BGE? I’d be very thankful.

Thanks for your reply. Could you please show me how this can be done as I’m pretty new in BGE? I’d be very thankful.

in pose mode, select a bone, then in bone constraints tab in the properties window, add a copy rotation constraint and target a object,

you can rotate the target object with python or an animation or with logic bricks,

Thanks, I’ve tried what I’ve been doing in normal python not BGE found http://pasteall.org/99449 but when I do that and press W to rotate the bone during the game nothing appears, and once I finish the game running I found the bone rotation applied.

I am on a phone at the moment,
so I cant see your blend, but my guess is you are using bpy,

you cant use bpy inside the game engine*

use the bge api and you can set bone rotations using armature section of api, but it’s a bit rough

easier to manage a hierarchy of objects and make em invisible later,
and copy rot to then.

Thank you very much. Could you please show me a demo on just one bone on how this can be done? just whenever you have the chance as I’ll be very grateful. Thanks in advance

Could you please assist me with this and show me how this can be done in one bone? I’d really appreciate it.

sure, I will make a little demo today :slight_smile:

Thank you very much :slight_smile:

Attachments

Armature_Bendy_Demo.blend (418 KB)

ok, looking at your video you will probably want a tag on each bone of a ‘intial’ armature and then a ‘clone’ object that rotates to match the tag, and then also applies an offset you can keyframe in game?

then the ‘final’ armature copies rotations from the clone objects?

I don’t think kicking anything back and forth using bpy sounds fun at all, but it is possibe I think*

This is what happened in the video, like you can see the animation is stopped by pressing a key, then press x,y or z to select the rotation axis of the selected bone, then change rotation with uparrow and downarrow keys, then when the animation is replayed it is replayed some frames beforehand where the new rotation will be applied with smooth interpolation between it and the previous/next range of frames. Then I want to be able to save the new animated armature. Could you please show me how this can be done just for one bone on the animated armature I sent you? I always find it much more helpful learning by examples, and I always do this with my friends as I taught many friends of mine blender, and I’ve already done that in bpy but I’m just new to BGE and I want to do it in BGE so I’d really appreciate your kind help and assistance.

basically you need to seperate display of animation from the animation,

and any keyframes you edit, must be passed back to a bpy server that applies your changes and then tells bge to libload the new armature / animation and burn the old one.

oh okay, thank you for the clarification. Could you please show me how this can be done? because I have no clue how it can be done, just whenever you have any free time please, I’d be very grateful.