How to use blendspaces from C++?

I am trying to use my custom .bspace file from C++, the file on its own is perfectly fine, character tool properly works with it and not only.
I managed to run it with StartAnimation("animation", animParams) method, but I don't know how to blend them. I have two dimensions. BlendWeight and BlendWeight2. I used that :

Code: Select all

That is inside this method: CPlayer::PostInit(IGameObject *pGameObject); __________________________________________________________________________________________________________________ pAnimChar = static_cast<IAnimatedCharacter*>(GetGameObject()->AcquireExtension("AnimatedCharacter"));
And then I am blending all that this way:

Code: Select all

pAnimChar->SetBlendWeightParam(eMotionParamID_BlendWeight2, blendFloat);
and it seems to work as I wanted with only one issue......
Wherever I use this line :

Code: Select all

pAnimChar = static_cast<IAnimatedCharacter*>(GetGameObject()->AcquireExtension("AnimatedCharacter"));
My character's movement blendspaces stop working! It only plays forward run animation. Once I comment it out my movement blendspaces come back and they work properly in all directions. It's weird, but without this line I probably won't be able to use SetBlendWeightParam method. Any ideas?
Cryengine tutorial videos on my Youtube channel! Check it out !

Re: How to use blendspaces from C++?

you need mannequin.
configure blendspace.

setup fragment id and fragment

c++ set paramter .

search source code keywords

eMotionParamID_TravelAngle, //!< Forward, backwards and sidestepping.
eMotionParamID_TurnAngle, //!< Idle2Move and idle-rotations.
eMotionParamID_TravelDist, //!< Idle-steps.

CalculateCompleteBlendSpaceDuration ... Sample.cpp

Re: How to use blendspaces from C++?

Thank you for help mknmknmknjk !

With all hints you gave to me I managed to work on my custom blendspaces! It was so simple, but I will show below how to do that, so the others can learn.

How to work on blendspaces from C++?
1. First of all, you need to have your .bspace file properly set up. It is important what dimensions you're gonna use. I mean their names. For example you're using BlendWeight and BlendWeight2 (obviously you can use more, that's just example).
2. You need to create FragmentID and Fragment where you're gonna put your blendspace in. It could be already used FragmentID, although you'll have to find it's execution in the code.
Note: I am not going to go over whole process of building .bspace files and running Fragments from C++ you can find info about that in mknmknmknjk's post.
3. Once your fragment is running :

Code: Select all

You need to use code below inside of your update function. It is important for it to be updated every frame:

Code: Select all

pCharacter->GetISkeletonAnim()->SetDesiredMotionParam(eMotionParamID_BlendWeight, blendRatio, 0.f);
eMotionParamID_BlendWeight could be anything else. There is more parameters you can manage. Dig inside of the code for it. (CryCharAnimationParams.h)

Thanks and I hope someone will make use of it.
Cryengine tutorial videos on my Youtube channel! Check it out !

Who is online

Users browsing this forum: No registered users and 3 guests