Proper way to blend animations/animating transitions

Hey there,

I’ve come up with some makeshift fixes for this kind of issue, and I’m just wondering what’s really the best way to go about it; not necessarily looking to get deep into the intricacies of the logic and/or code (be running armatures with python, because I swing that way), just want to know how other people deal with it.

Let’s say for instance, on running or walking towards a wall we want our character to rotate approximately one hundred and eighty degrees in the zed axes so that their back touches said wall, for taking cover, walking over a ledge or doing stealthy metal gear/tenchu-like stuff. We can’t just play pose one to pose two back-to-back, because it’ll either not look smooth enough or get the armature very confused and twisting in impossible ways.

What I’d usually do in this situation is think of it as a three-part action sandwich, played in sequence: the action that was playing at the time the sequence triggers --> a transition where I do the rotation --> and then an idle loop where the character’s back is always against the wall. I’ll refer to this sequence as A --> B --> C.

My solution is, and has been for some time, putting A on lowest layer, then stacking B on top of it so that I can utilize action blending and layer weight, and then C on top of it all. Sometimes, if I’m getting funky with the controlling cube’s world position (like when climbing up walls), I’ll skip the whole layering and blending steps and just make A, B and C fit together perfectly in sequence, by copying and pasting the last pose of A into the first pose of B, and then skipping it so that I don’t play the same frame twice.

Just how sane is this approach? Is there a simpler solution I’m not considering? I’d really like to know other methods, it’s been next to impossible finding much mention of this topic.

use logic…

have the hit box cast rays, and when cover is detected + keypress go into a state that transitions into ‘cover mode’ for that item.

check this out


def function_1(info):
    #importantStuff

def function_2(info):
    #otherImportantThing


commandDict = { "function_1":function_1, "function_2":function_2 } 

later you can grab the action string from the intended obstacle you use to cover using a ray.

import bge

def main():
    cont = bge.logic.getCurrentController()
    ray = cont.sensors['ray']
    if ray.positive:
        functionString = ray.hitObject['CoverType']
        function = commandDict[functionString]
        function()

another thing to do,
make a animation, strip out the root keys, and do those with logic instead basically.

I am of the school that translating the player, rotating the player, applying forces should all be done with code not animations.

have you seen object.getVectTo(other)?

what about - https://docs.blender.org/api/2.78a/mathutils.geometry.html?highlight=point%20line#mathutils.geometry.intersect_point_line ?

Aww, but I do use some logic. I just don’t feel comfortable with action actuators. I have a module that contains all animations and assigns them their respective mode, layer, frame range, etcétera. Then I can just call them with a string and a dict lookup, play and stop them with functions that can also trigger state changes if I tell them to. Still, your way seems clever, and much more simplified. I’ll take note.

I don’t exactly recall right now but I think I was getting the distance with getVectTo(ray.hitPosition) or something along those lines, then applying movement with code. IMO in this example it’d just look better to have him actually turn around rather than just waggle feet and shoulders as the controller rotates, shame it’s unpractical.